Интеграция полос возвращает ошибку cors 400 - PullRequest
0 голосов
/ 06 мая 2020

перенаправлено: false
status: 400
statusText: «Bad Request»
type: «cors»
url: «https://api.stripe.com/v1/customers»

вернуть эту ошибку.

    let customer= {
            "name": "xxxxxx",
            "phone": "xxxxxxxxxx",
            "email": "sxxxxxxa@gmail.com",
            "description": "test account "
        }

        let url = 'https://api.stripe.com/v1/customers';

        let body = {
            method: 'POST',
            headers: {
                'Content-Type': 'application/form-data',
                'Authorization':'Bearer sk_test_xxxxxxxxxxxxxxxx',
                'Stripe-Version': '2014-12-22',
            },
            //body: JSON.stringify(customer),
//json:true
            body: customer
        }

        let response = await fetch(url, body);
        console.log("response ",response.type)
        if (response.ok) {
            let json = await response.json();
        } else {
            console.log("err",response)
        }

1 Ответ

0 голосов
/ 20 мая 2020

Stripe docs говорит, что запрос был неприемлем, часто из-за отсутствия обязательного параметра. для 400 неверных запросов.Поэтому проверьте документы API отсюда и проверьте, чего не хватает.

https://stripe.com/docs/api/customers/create

...