W
W
Wyzert2019-05-15 20:11:59
JavaScript
Wyzert, 2019-05-15 20:11:59

Node.js module | How to get body out of request?

const request = require('request');

request({
    uri: 'mysite.com/somejson.json'
}, function(error, response, body){
    // код здесь
}

How can I output body to some variable? Or to receive the answer at once through return in function? Is there any other way?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Shvedov, 2019-05-15
@mmmaaak

Promise

S
Stockholm Syndrome, 2019-05-15
@StockholmSyndrome

How can I output body to some variable? Or to receive the answer at once through return in function? Is there any other way?

what for?
you have to work with this variable inside the function

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question