Javascript 401 Error on Fetch (mutation)

Can some explain to why this plain vanilla JS returns a 401 error?

fetch(“https://api.monday.com/v2”,{
mode: ‘no-cors’,
method: ‘post’,
headers: {“Authorization”: sToken,
“Content-type”: “application/json”,
“Accept”: “application/json”,
“Access-Control-Allow-Origin”: “*”,
“Access-Control-Allow-Credentials”: “true”},
body: JSON.stringify(sQry)}
)

Both sToken and sQry are correctly assigned beforehand.

Hey there! Thanks for posting in the community :slight_smile:

If you’re getting a 401 error, there’s probably something wrong with your token or query. Can you please share how you’re assigning sToken and sQry so we can get to the bottom of it?

Please don’t share the actual token, but it’ll be useful to see how you’re assigning those variables.

Hi @enlightened, Can you elaborate more on what is the error message? we can do it in a private chat also