I need to invoke restful webservices in Sproutcore which requires authentication header for http request. I write a code like in Sproutcore:
authHeader: function () {
var userAndPass = "username:password";
var auth = "Basic " + Base64.encode(userAndPass);
return auth;
},
However, when I run it, sadi Base64 is not defined.
Anybody knows how to fix it or do it in sproutcore. Thanks
Use btoa()
for Base-64 encodeing.
var auth = "Basic " + btoa(userAndPass);