node.js – Google Cloud Storage – Uploading image PUT request, no JSON response – JavaScript

Your response needs to be resolved properly.

Making an API call and resolving the promise will get you the response of the call’s headers. Like, ok: true and status: 200. To get the data response, you need to resolve it too.

I think the reason for this is that you may not always have a data response you want to check or if there’s a non-200 response status code, then you won’t want to unwrap the data. Possibly also performance related.

To get the data you want:

  • resolve your initial API call promise (which you’re already doing).
  • once resolved, then resolve your data stream by calling .json() on your body.

Read more here: Source link