Hey i made an webserver with nodejs and express if i sent a request to ip/test it give me text via res.send(‘test)
i want to fetch this text via sweetalert but it always fail :/
The JavaScript Code:
const ipAPI = 'http://ip:port/test'
Swal.queue([{
title: '',
confirmButtonText: 'Click me',
showLoaderOnConfirm: true,
preConfirm: () => {
return fetch(ipAPI)
.then(response => response.html())
.then(data => Swal.insertQueueStep(data))
.catch(() => {
Swal.insertQueueStep({
icon: 'error',
title: ':('
})
})
}
}])
And the Nodejs Express Code:
app.post('/test', function(req, res){
res.send(globalServerCount);
});
Advertisement
Answer
i found the answer:
app.get('/test', function(req, res){
res.send(globalServerCount);
});