为什么可以使用Anguler API初始化Paystack付款

时间:2019-05-07 05:35:57

标签: angular http-headers nativescript http-error

我共享了一个Anguler + NativeScript代码项目,我想使用PayStack API进行付款,但是当我尝试对此URL进行请求时ttps://api.paystack.co/transaction/initialize什么也没发生。

下面是我的代码,有人可以帮我吗?

import {  HttpClient,HttpErrorResponse, HttpHeaders } from '@angular/common/http';


let postObject=
{
      'email':'000@gmail.com',
      'amount': 5000,
      'subaccount':'ACCT_....',
      'reference':'9979962247',

};

const headers = new HttpHeaders();
headers.set('Content-Type', 'application/json; charset=utf-8');
headers.set('Authorization','Bearer sk_test_...');

this.http.post('https://api.paystack.co/transaction/initialize', JSON.stringify(postObject), {headers: headers}).subscribe(
        (data:any) => {
            console.log(data);
        },
        (err: HttpErrorResponse) => {
            if (err.error instanceof Error) {
                console.log('Client-side error occured.');
            } else {
                console.log('Server-side error occured.');
            }
        }
    );
    

0 个答案:

没有答案