0
0

More than 1 year has passed since last update.

RailsのAPIをブラウザのコンソールから呼ぶ

Last updated at Posted at 2021-11-01

POST

await (await fetch('/example/api', {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'X-CSRF-Token': document.querySelector("meta[name='csrf-token']").getAttribute('content')
  },
  body: JSON.stringify({
    params1: 'パラメータ1',
    params2: 'パラメータ2',
  })
})).json()

GET

await (await fetch('/example/api')).json()
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0