AnsweredAssumed Answered

Empty AJAX response when URL works fine in browser

Question asked by Luke Ramus on Nov 30, 2017
Latest reply on Dec 5, 2017 by Luke Ramus

I'm trying to retrieve Canvas data for a project where I work, which self-hosts Canvas for its faculty and students. I'm using Fetch API (but have tried with other ajax methods too). However, anytime I try to GET something I just get an empty response back. Body is null and statusText is empty. 


The thing that's weird is if I access the URL directly in my browser, I see the JSON just fine. But when I Fetch with the exact same URL I just see an empty response. For example, in the browser shows me my ID, name, sortable name, etc. Hitting that with a GET fetch gives just an empty response.


Status of the call is 200 and I'm not getting any CORS errors or anything like that, so as far as I can tell it's going through OK.


Any thoughts?


Thanks everybody!!

var token = // my temp token here
var url = '';

var headers = new Headers();
headers.append('Authorization',`Bearer ${token}`);

var options = {
  method: 'GET',
  credentials: 'same-origin',

fetch(url, options).then(function(response) {