shuuuuun
5/14/2019 - 1:57 AM

corsとか確認する用

corsとか確認する用

// GET
fetch('https://example.com/api/count.json', {method: 'GET', mode: 'cors'}).then(r => r.json()).then(r => console.log(r))

// 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', body, headers}).then(r => r.json()).then(r => console.log(r))