首页 > 解决方案 > 根据请求,braintree-web API 中位置 1 处 JSON 中的意外令牌 o

问题描述

我已将 Braintree 集成到我的 Angular 7 应用程序中。但我有一个错误。到目前为止我已经搜索但无法获得解决方案。

错误::

zone.js:199 Uncaught SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
    at wk (fb.js:1)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
    at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:498)
    at invokeTask (zone.js:1744)
    at globalZoneAwareCallback

index.html::

<script src="https://js.braintreegateway.com/web/3.46.0/js/client.min.js"></script>

App.component.ts::

declare var braintree:any;

export class AppComponent implements OnInit {

    ngOnInit(){
        braintree.client.create({
            authorization: 'token'
            }, function (createErr, clientInstance) {
            clientInstance.request({
                endpoint: 'payment_methods/credit_cards',
                method: 'POST',
                data: {
                    creditCard: {
                        number: '4111111111111111',
                        cvv: '123',
                        expirationDate: '12/23'
                    }
                }
                }, function (requestErr, response) {
                    console.log(response)
            });
        });
    }
}

参考链接::braintree-web

请告诉我,如何解决这个问题。

标签: angular7braintree

解决方案


推荐阅读