Im getting 500 ReferenceError: localStorage is not defined
in the controller of my Rendr app. Im trying to fetch my Authorization token from localStorage and set it as a header before I fetch the spec. I've also tried window.localStorage but then I get window is not defined. Do I not have access to the window object in the controller level? If not, how would I fetch from localStorage.
This is my code for the controller.
module.exports = {
show: function(params, callback) {
var spec = {
model: {
model: 'Company', params: { name: params.id }
}
};
var options = {},
Authorization = localStorage.getItem('Authorization');
options.header = {
"Authorization": Authorization
}
this.app.fetch(spec, options, function (err, results) {
// return if there is an error fetching the user
if (err) return callback(err);
// set the title of the page to the users name
this.app.set('title', results.model.get('name'));
// render the page with the results from the fetch
callback(null, results);
}.bind(this));
}
};