Answer the question
In order to leave comments, you need to log in
Why does it return ReferenceError: body is not defined?
const request = require("prequest")
const token = "СЕКРЕТ"
module.exports = (id) => {
request("https://api.vk.com/method/users.get?token="+token+"&user_ids="+id+"&v=5.131", (error, response, body) => {
console.log(body)
})
return body
}
Answer the question
In order to leave comments, you need to log in
try another library like axios
const axios = require("axios");
const token = "СЕКРЕТ";
module.exports = (id) => {
axios.post("https://api.vk.com/method/users.get", {
params: {
'token': token,
'user_ids': id,
'v': '5.131'
}
}).then((res) => { console.log(res) /* или console.log(res.data), чтобы вывести ответ от ВК */ }).catch((err) => { console.log(err) });
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question