我试图用取发送POST请求OneSignal REST API:反应本地取“不支持BodyInit型”
var obj = {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
'app_id': '(API KEY)',
'contents': {"en": "English Message"},
'app_ids': ["APP IDS"],
'data': {'foo': 'bar'}
})
}
fetch('https://onesignal.com/api/v1/notifications', obj)
我知道你不是真的应该把你的API密钥客户端代码,但这只是一个测试,看看它是否会起作用。另外,我发现了错误不是来自服务器的响应不好,它是:
Possible Unhandled Promise Rejection (id: 0):
unsupported BodyInit type
我试图把一个catch
方法上取,但它不会被调用。
有点遗憾,不确定如何继续。
在此先感谢!