xxxxxxxxxx
A GET request cannot have a body. That's just how it is. You're going to have to make a POST request that returns JSON data.
xxxxxxxxxx
const fetch = require('node-fetch');
const url = 'https://example.com/api/endpoint';
const requestBody = JSON.stringify({ key: 'value' });
fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
body: requestBody,
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));