I am making an ajax call using fetch. When I use no-cors, the Authorization header disappears. If I use cors, the Authorization header is there, but I get cors error. I want to disable cors (no-cors), but it I get 401 (unauthorized) error since the Authorization header inexplicably disappears. Thx
fetch("https:...", {
method: "GET",
mode: "no-cors",
withCredentials: true,
credentials: 'include',
headers: {
Authorization: "Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzaW5nYXB1QE1GQ0dELkNPTSIsImlzcyI6IktlcmJlcm9zUHJvdmlkZXIiLCJhdWQiOiJLZXJiZXJvc1Byb3ZpZGVyIiwicHJlZmVycmVkX3VzZXJuYW1lIjoic2luZ2FwdUBNRkNHRC5DT00iLCJraWQiOjEyNjMsImV4cCI6MTYxMTE1MzI4NCwiaWF0IjoxNjExMTEwMDg0fQ.Dz5vQfwZoU-bIzWJ8lsY1T_dHIqwGyL9rZxM8eG4n74"
}
})
.then(response => response.json())
.then(data => {
console.log(data)
})
.catch(error => console.error(error))