Last active
September 7, 2022 13:37
-
-
Save shuuuuun/9760aa4374d1b1ae8ee831f4e1755417 to your computer and use it in GitHub Desktop.
corsとか確認する用
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GET | |
fetch('https://example.com/api/count.json', {method: 'GET', mode: 'cors'}).then(d => d.json()).then(console.log).catch(console.error) | |
// POST | |
const headers = new Headers() | |
headers.append('Content-Type', 'application/json') | |
const body = JSON.stringify({ hoge: 'fuga' }) | |
fetch('https://example.com/api/count.json', {method: 'POST', mode: 'cors', credentials: 'include', body, headers}).then(d => d.json()).then(console.log).catch(console.error) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ http https://example.com/api/count.json Origin:'https://hogehoge.com'