Accepted answer

in order to access the data from a readablestream you need to call one of the conversion methods (docs available here).

as an example:

  .then(function(response) {
    // the response is a response instance.
    // you parse the data into a useable format using `.json()`
    return response.json();
  }).then(function(data) {
    // `data` is the parsed version of the json returned from the above endpoint.
    console.log(data);  // { "userid": 1, "id": 1, "title": "...", "body": "..." }

edit: if your data return type is not json or you don't want json then use text()

as an example:

  .then(function(response) {
    return response.text();
  }).then(function(data) {
    console.log(data); // this will be a string

hope this helps clear things up.


i just had the same problem for over 12 hours before reading next, just in case this helps anyone. when using nextjs inside your _api page you will need to use json.stringify(whole-response) and then send it back to your page using res.send(json.stringify(whole-response)) and when it's received on the client side you need to translate it back into json format so that it's usable. this can be kinda figured out by reading their serialization section. hope it helps.


i dislike the chaining thens. the second then does not have access to status. as stated before 'response.json()' returns a promise. returning the then result of 'response.json()' in a acts similar to a second then. it has the added bonus of being in scope of the response.

return fetch(url, params).then(response => {
    return response.json().then(body => {
        if (response.status === 200) {
            return body
        } else {
            throw body


if you just want the response as text and don't want to convert it into json, use and then then it to get the actual result of the promise:

  .then(function(response) {
    response.text().then((s) => console.log(s));


  .then(function(response) {
    return response.text();
  .then(function(mytext) {


note that you can only read a stream once, so in some cases, you may need to clone the response in order to repeatedly read it:

  .then( json => console.log(json))

  .then( text => console.log(text))


little bit late to the party but had some problems with getting something useful out from a readablestream produced from a odata $batch request using the sharepoint framework.

had similar issues as op, but the solution in my case was to use a different conversion method than .json(). in my case .text() worked like a charm. some fiddling was however necessary to get some useful json from the textfile.


res.json() returns a promise. try ...

res.json().then(body => console.log(body));


some people may find an async example useful:

var response = await fetch("");
var body = await response.json(); // .json() is asynchronous and therefore must be awaited

json() converts the response's body from a readablestream to a json object.

the await statements must be wrapped in an async function, however you can run await statements directly in the console of chrome (as of version 62).

Related Query

More Query from same tag