我在尝试为 SMS Eagle 制作网络应用程序时遇到了这个烦人的问题。 我正在尝试向 SMS Eagle 服务器发送 API 请求,然后发送 SMS,这是成功的,但唯一的问题是我似乎无法获取响应正文。
在 Javascript 中,当我查看响应正文属性时,该值为“空”。但是当我查看网络选项卡时,我看到了值。请注意还有 'status: 0' 和其他看起来很奇怪的值。
我尝试使用 response.json()、response.text()、response.blob() 等获取值。我在这里做错了什么?我也已经尝试过多个内容类型的标题。这是我的代码:
fetch(`http://x.x.x.x/http_api/send_sms?login=${login_g}&pass=${pass_g}&message=${encodeURIComponent(message)}&to=${number}`, { method: 'GET', mode: 'no-cors', headers: { 'Content-Type': 'text/plain'}})
.then(response => response.text())
.then(data => console.log(data));
亲切的问候, 碧玉