如何解决通过sweetalert从快递服务器获取数据
嘿,我用nodejs制作了一个网络服务器并表示 如果我发送了ip / test请求,它会通过res.send('test)
给我发短信我想通过sweetalert获取此文本,但它总是失败:/
JavaScript代码:
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: ':('
})
})
}
}])
以及Nodejs Express代码:
app.post('/test',function(req,res){
res.send(globalServerCount);
});
解决方法
我找到了答案:
app.get('/test',function(req,res){
res.send(globalServerCount);
});
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。