📌
ブラウザのコンソールからAPIをPOSTで叩く方法
const url = 'https://httpbin.org/';
const data = { username: 'example' };
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.error('Error:', error));
参考
Discussion