0

Trying to get the body of the body using fetch and with the authentication of adobe. I always get this 200 response (means okay) but I cannot the actual response of body like in postman.

[Symbol(Response internals)]: {
    url: url_of_adobe,
    status: 200,
    statusText: 'OK',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
  }

Here's my code

const fetch = require("node-fetch");
const fs = require("fs");

fetch(url, {
    'method': 'GET',
    'Content-Type': 'application/json',
    'headers': {
        'x-gw-ims-org-id': org_id,
        'x-api-key': api_key,
        'Authorization': `Bearer ${accessToken}`, 
    },
    
}).then((response) => console.log(response))
    .catch((error) => console.log(error));

1 Answers1

0

Content-Type should be in the header

'headers': {
        'Content-Type': 'application/json',
        'x-gw-ims-org-id': org_id,
        'x-api-key': api_key,
        'Authorization': `Bearer ${accessToken}`, 
    },

And if you want to read the response in json format you have to use .json() on the response

.then((response) => console.log(response.json()))
    .catch((error) => console.log(error));