私はブラウザにフェッチAPIを介してたるみメッセージを投稿しよう:スラックの着信ウェブフック:リクエストヘッダフィールドのコンテンツタイプは、プリフライト応じてアクセス制御 - 許可 - ヘッダによって許可されていない
fetch('https://hooks.slack.com/services/xxx/xxx/xx', {
method: 'post',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-type': 'application/json'
},
body: JSON.stringify({text: 'Hi there'})
})
.then(response => console.log)
.catch(error => console.error);
};
I次のエラーメッセージが表示されます。
Fetch API cannot load:
https://hooks.slack.com/services/xxxxxxx/xxxxx.
Request header field Content-type is not allowed by Access-Control-Allow-Headers in preflight response.