S
S
Spokich2019-09-24 12:19:50
Node.js
Spokich, 2019-09-24 12:19:50

Why is the Request module in Node.JS static?

Good day everyone, I'm interested in the question of the request module. When you run the script on NodeJS, everything works correctly, it takes the necessary information and displays it correctly, but the fact is that the information that I request on the site is constantly updated, and the script itself uses the version that was taken during the script launch, and so, How can I make this request dynamic so that the output information is received at the time of the request and not at the time the script is run.

request('url', function(err, resp, body) {
            const $ = cheerio.load(body);

            var t = $('option').contents().map(function() {
                return (this.type === 'text') ? $(this).text() : '';
            }).get().join('\

            message.channel.send(t)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2019-09-24
@Spokich

use the version that was taken at the time the script was run

Maybe because you are making this request when the script itself is running?
Node.js is a process that you run and it hangs in memory, if you want this request to "run" only when your script is requested from the browser, then put this code in the callback of the request from the browser

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question