I am trying to recreate this POST request to a local Ruby on Rails API I am writing but I don’t seem to be able to configure Postman correctly to execute my request. Any help will be appreciated!
var csrfToken = document.querySelector('[name=csrf-token]')
fetch('http://localhost:3000/api/v1/todo_items', {
credentials: 'include',
headers: {
accept: 'application/json, text/plain, */*',
'accept-language': 'en-US,en;q=0.9',
'cache-control': 'no-cache',
'content-type': 'application/json;charset=UTF-8',
pragma: 'no-cache',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'x-csrf-token': csrfToken.content,
},
referrer: 'http://localhost:3000/',
referrerPolicy: 'strict-origin-when-cross-origin',
body: '{"post":{"title":"A new todo item","body": "asdsadasd", "user_name": "shannarra"}}',
method: 'POST',
mode: 'cors',
})