#nickh-nodejs-rawhttp
1 messages ยท Page 1 of 1 (latest)
Not sure, I've never written code like this before. Doesn't Zapier support making Stripe API Requests direcrtly?
nickh-nodejs-rawhttp
it does as a BETA thing yes...
ironically,I thought raw might be more stable ๐
anyway yeah body seems totally empty...
I checked the Stripe log
if youre able to access my account as Stripe Admin: https://dashboard.stripe.com/test/logs/req_0zGfgZxXJ0UZpV?t=1690300577
yeah so it means you never passed the parameter properly in this case
hmmmm
`let data = new URLSearchParams();
data.append('type', 'express');
fetch('https://api.stripe.com/v1/accounts', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic ' + Buffer.from('sk_test_REDACT:').toString('base64')
},
body: data
}).then(function(res) {
return res.json();
}).then((json) => {
callback(null, json);
});`
not sure what could be wrong with that...
why are you using URLSearchParams for something like this though?
what's the alternative?
(because Stripe API doesn't accept JSON? - it said I had to form-urlencoded)
um, apparently this is the alternative... eg::
var formBody = []; for (var property in details) { var encodedKey = encodeURIComponent(property); var encodedValue = encodeURIComponent(details[property]); formBody.push(encodedKey + "=" + encodedValue); } formBody = formBody.join("&");
then: body: formBody
would be nice if Stripe API accepted JSON like every other API out there ๐
sure