缓冲区未在JavaScript中定义

发布于 2025-02-12 22:44:59 字数 1211 浏览 0 评论 0原文

我正在尝试通过使用以下代码将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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文