I'm reading data from a page.
But I would like to read this data every 3 seconds or every time the node has finished reading the data.
I'm using this function here:
const getScript = (url) => {
return new Promise((resolve, reject) => {
const http = require('http'),
https = require('https')
let client = http
if (url.toString().indexOf('https') === 0) {
client = https
}
client.get(url, (resp) => {
let data = ''
// A chunk of data has been recieved.
resp.on('data', (chunk) => {
data += chunk
})
// The whole response has been received. Print out the result.
resp.on('end', () => {
resolve(data)
})
resp.destroy()
}).on('error', (err) => {
reject({error: err})
})
})
};
In the first moments he reads, but then he starts giving the message below
{ Error: read ECONNRESET
at TCP.onread (net.js:656:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' } }
Is it because the page gets busy?
Thanks for the help