AnsweredAssumed Answered

Javascript access to API via access_token

Question asked by Uri A on May 13, 2020
Latest reply on May 15, 2020 by James Jones

Hi,

 

I'm trying to make a web app that should interface with canvas data via the API. I know that eventually I need to get it working with the OAuth system, but for development I wanted to get it working with an access token. My code looks like the below (essentially copied from another thread here), but it gives a failed to fetch error.

 

In another tab on the browser, I am logged into canvas. 

Any help would be much appreciated. Thanks.

 

const apiToken = <TOKEN HERE>;
const options = {
'method': 'GET',
'headers': {
'authorization': 'Bearer ' + apiToken,
'content-type': 'application/json',
'accept': 'application/json'
},
'timeout': 5000
};
let outputfromcanvas;
.then(res=>{outputfromcanvas = res; console.log(res)})
.catch(err=>console.log("err: ", err))

Outcomes