#Question about SDK behavior with statusCode 201

3 messages · Page 1 of 1 (latest)

lunar kelp
#

Hey everyone 👋

Has anyone experienced an issue with the SDK when fetching an API that returns a statusCode 201?

In my case, the API request works correctly (the resource is created successfully), but the SDK doesn’t seem to handle the response as expected.

Just wanted to check if this is known behavior or maybe a bug before digging deeper.

Thanks in advance for any insights

lunar arrow
#

Could you provide more information as to what you mean by "the SDK doesn't seem to handle the response as expected"?

Also, what version of the sdk are you using and what is the endpoint you are calling with it?

Lastly, what Medusa version are you on?

lunar kelp
#

Hey @lunar arrow
Sure !
I'm using the medusa version 2.10.3
I'm calling in my storefront (nextjs) app a custom query

    await sdk.client.fetch<any>(`/store/quotes/${quoteId}/accept`, {
      method: 'POST',
      headers,
    });

This api return return res.sendStatus(201);

In my storefront I get Error: Unexpected token 'C', "Created" is not valid JSON

To get it working i need to return return res.json({}); in the api.

Let me know if you need more info 😉