Я продолжаю получать эту ошибку раздражения. Кто-нибудь знает, как это решить? Это делает запрос http, но где-то кажется, что я пропускаю JSON.stringify.
app.js
let server = http.createServer(function (req, res) {
path = req.url;
if (path === undefined || path === '/') {
res.end('Welcome... all-about-clash site.');
} else {
const options = {
host: 'api.clashofclans.com',
path: path,
url: 'https://api.clashofclans.com' + path,
method: 'GET',
json: true,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer token'
}
};
request(options, (error, response, body) => {
if (!error) {
res.write(JSON.stringify(body));
res.end();
} else {
res.write(JSON.stringify(error));
res.end();
}
});
}
});