Answer the question
In order to leave comments, you need to log in
Synchronous function execution in node.js?
I decided to study the node, and ran into a problem: I
wrote a function
var requestSync = require('sync-request');
function getts() {
var getts = requestSync('GET', 'https://api.vk.com/method/messages.getLongPollServer?need_pts=1&access_token='+token);
var data = JSON.parse(getts);
var key = (data.response.key);
var ts = (data.response.ts);
var pts = (data.response.pts);
}
Answer the question
In order to leave comments, you need to log in
This module makes a synchronous request to the server and the node has nothing to do with it. Have you tried reading the
documentation ?
To get a response from the server, you need to call the getBody () method on getts
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question