缓冲区未在JavaScript中定义
我正在尝试通过使用以下代码将vm.getInput.path.path.path.path
编码为base64。问题在于我遇到了未定义缓冲区的错误。
function get() {
resetResults();
RetrieveObjects.resource.get(
{
chain: vm.getInput.chain,
dataCenter: vm.getInput.dataCenter,
path: Buffer.from(vm.getInput.path).toString('base64')
},
function successCallback(response) {
vm.result = response.getResult;
console.log(response)
},
function errorCallback(response) {
vm.error = response;
}
);
}
错误
angular.js:13294 ReferenceError: Buffer is not defined
at RetrieveObjects.get (RetrieveObjects.controller.js:64:27)
at fn (eval at compile (angular.js:14138:15), <anonymous>:4:253)
at expensiveCheckFn (angular.js:15151:18)
at callback (angular.js:24674:17)
at Scope.$eval (angular.js:16895:28)
at Scope.$apply (angular.js:16995:25)
at HTMLInputElement.<anonymous> (angular.js:24679:23)
at HTMLInputElement.dispatch (jquery.js:4737:27)
at elemData.handle (jquery.js:4549:28)
我不知道如何解决该问题。我一生中的第二次使用JavaScript。
I am trying to encode vm.getInput.path
to base64 by using the following code. The problem is that I am getting the error that Buffer is not defined.
function get() {
resetResults();
RetrieveObjects.resource.get(
{
chain: vm.getInput.chain,
dataCenter: vm.getInput.dataCenter,
path: Buffer.from(vm.getInput.path).toString('base64')
},
function successCallback(response) {
vm.result = response.getResult;
console.log(response)
},
function errorCallback(response) {
vm.error = response;
}
);
}
Error
angular.js:13294 ReferenceError: Buffer is not defined
at RetrieveObjects.get (RetrieveObjects.controller.js:64:27)
at fn (eval at compile (angular.js:14138:15), <anonymous>:4:253)
at expensiveCheckFn (angular.js:15151:18)
at callback (angular.js:24674:17)
at Scope.$eval (angular.js:16895:28)
at Scope.$apply (angular.js:16995:25)
at HTMLInputElement.<anonymous> (angular.js:24679:23)
at HTMLInputElement.dispatch (jquery.js:4737:27)
at elemData.handle (jquery.js:4549:28)
I don't know how to solve that issue. Second time in my life I use Javascript.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论