const key = ""
const oWX_URL = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key='+key;
const sent_msg = {
'msgtype': 'text',
'text': {
'content': '已完成!'
}
};
const headers = {
'Content-Type': 'application/json'
};
fetch(oWX_URL, {
method: 'POST',
headers: headers,
body: JSON.stringify(sent_msg)
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
// Handle the response data here
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
});
标签:机器人,const,微信,Javascript,headers,text,key,error,response
From: https://www.cnblogs.com/knva/p/17722378.html