D
D
Danil Sitdikov2018-02-14 07:43:45
JavaScript
Danil Sitdikov, 2018-02-14 07:43:45

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

2 answer(s)
E
enchikiben, 2018-02-14
@EnChikiben

https://stackoverflow.com/questions/11826384/calli...

M
mrxakerrus, 2018-02-14
@mrxakerrus

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 question

Ask a Question

731 491 924 answers to any question