Closed aravindanve closed 7 years ago
Hey @aravindanve, thanks for raising this issue.
We need to do a better job handling an empty API response body, specifically with a 204
status. Although this conforms with JSON API spec, the fetch
polyfill will throw an exception as there's no JSON in the response to parse in the parseJSON
function 👇
I'll improve the parseJON
function to handle an empty 204
response and cut a new patch release today.
@ynnoj awesome, thanks!
Also, you may need to update the docs here: https://moltin.api-docs.io/v2/products/delete-a-product
@aravindanve Noted, thanks!
Hi,
When I call
gateway.Products.Delete(UUID)
, my code breaks with UnhandledPromiseRejectionWarning. I can't seem to catch the error by.catch(e => console.log(e))
either.I tested the API endpoint directly. That seems to work. Although, it returns an empty response, whereas, according to the docs, its supposed to return
{type: 'product', id: UUID}
. I think the sdk is trying to parse the empty response as JSON.I suspect the code at
src/utils/helpers.js
line42
is to blame. When I add a.catch()
to the line like this:response.json().catch(e => ...).then()
directly insidenode_modules
I'm able to catch this error: