i'm trying to convert this request :
curl https://api.stripe.com/v1/payment_links \
-u sk_test_dsgsdgsdgsdgsdyhwetdshsdhsdhsdhsdh: \
-d "line_items[0][price]"=price_1K7o9TFRZ3JYnODMxojDKSWp \
-d "line_items[0][quantity]"=1
to axios request : My array
const arrayOfPrices = [
{ price: 'price_1K7nrWFwZ3JYnODMD6Bb3SEy', quantity: 1 },
];
I have tried :
console.log(
new URLSearchParams({
arrayOfPrices,
})
);
return axios({
method: 'post',
url: 'https://api.stripe.com/v1/payment_links',
headers: {
Authorization: `Bearer ${process.env.STRIPE_PUBLIC_KEY}`,
Accept: 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
},
data: new URLSearchParams({
line_items: arrayOfPrices,
})
})
.then((res) => res.data)
.catch((err) => {
console.log(err.response.data);
return { status: 'fail', message: err.message };
});
And more different sets but it doesn't work.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment