O
O
olezhenka2017-06-07 16:19:33
PHP
olezhenka, 2017-06-07 16:19:33

How to get get request in node.js?

356daa0156c94d3d9c7f61e9903f5836.PNG
To receive it, you need to configure receiving in nginx? It looks like this for me:
location / vk {
proxy_pass http://127.0.0.1:81;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Odinets, 2017-06-07
@olezhenka

shta?
You send the user to the vk.auth/bla_bla link. Vkontakte redirects the user to the redirect_url (the link you provided) + adds its own GET parameters. All you need to do is add a processing route and get the GET parameters you are interested in

app.get('/vk/callback', function(req, res){
  var code = req.query.code;
});

Then you can send requests to VK api
var request = require("request");

request("api_url", 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