Using "Fetch"
Closed this issue · 2 comments
tyl330915 commented
I am using Fetch instead of Curl, and every time I try to get a token, I get a 422 "Unprocessable Entity" code. What am I doing wrong?
function datoJiToken() {
fetch("https://datoji.dev/tokens", {
headers: {
"Content-Type": "application/json",
},
method: "POST"
})
.then(response => console.log(response))
};
davidesantangelo commented
HI
I have received a success response with your code
function datoJiToken() {
fetch("https://datoji.dev/tokens", {
headers: {
"Content-Type": "application/json",
},
method: "POST"}).then(response => console.log(response.json()))
};
result: {data: {id: "b5892cab-2fa0-4042-a602-9393ece09ccd", type: "token", attributes: {key: "yCZAFL8Y0QjP2PJL5WEbEaubaqjlH0Vf", created_at: "2020-06-26T13:21:36.581Z"}}}
status: "resolved"
tyl330915 commented
Tried your code in both Firefox and Chrome, and still getting the 422 response.
body: ReadableStream
bodyUsed: false
headers: Headers {}
ok: false
redirected: false
status: 422
statusText: "Unprocessable Entity"
type: "cors"
url: "https://datoji.dev/tokens"