简体   繁体   English

Sproutcore中的Base64编码

[英]Base64 encoding in Sproutcore

I need to invoke restful webservices in Sproutcore which requires authentication header for http request. 我需要在Sproutcore中调用宁静的Web服务,这需要HTTP请求的身份验证标头。 I write a code like in Sproutcore: 我在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. 但是,当我运行它时,没有定义sadi Base64。

Anybody knows how to fix it or do it in sproutcore. 任何人都知道如何修复它或以发芽方式进行操作。 Thanks 谢谢

使用btoa()进行Base-64编码。

var auth = "Basic " + btoa(userAndPass);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM