Answer the question
In order to leave comments, you need to log in
Node.js how to make a json request to another site?
const http = require('http');
http.createServer(function(req, res) {
http.get(url,an =>{
}).on('error', console.error);
res.writeHead(200,{ 'contents-type':'aplication /json' });
res.end('1');
}).listen(3000,()=>{'start server'}) It's
not much of an impudent question, but there's little time to figure it out. Who will help I will be very grateful. How to make a GET request to another domain to get json. The server receives a link to this domain from the client. I'm not writing a big front and can't do cross-domain requests. If anyone knows how to do cross-domain from a client, it would be interesting to know).
Answer the question
In order to leave comments, you need to log in
varrequest = require('request');
var fs = require('fs');
var options = {
url: "Here is the address of the site to make a request to",
};
request.get(options, function(error, response, body){
console.log(body);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question