Help

Re: Airtable Scripting not parsing Stripe API response

572 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Jonathan_Straus
5 - Automation Enthusiast
5 - Automation Enthusiast

I’m trying to use an Airtable Automation script to lookup a customer ID in the Stripe API. My fetch call is returning a 200 but the data object is empty in the Airtable script even though the same call has a valid JSON response via curl in terminal.
Screen Shot 2022-09-13 at 9.49.40 AM
Screen Shot 2022-09-13 at 9.51.55 AM

Here’s the full script code:

let Stripe_API = 'YOUR_STRIPE_API_KEY';
let Stripe_URL = 'https://api.stripe.com/v1/customers/cus_MQGV6PEdpS1RWJ';
    
let options = {
    method: 'GET',
    headers: {
        'Authorization': 'Bearer ' + Stripe_API 
    }
};
console.log(options);

let response = await fetch(Stripe_URL, options);
console.log(response);

Does anyone have ideas about why Airtable isn’t recognizing the full response from the Stripe API?

1 Reply 1
Jonathan_Straus
5 - Automation Enthusiast
5 - Automation Enthusiast

FYI, found the fix (use response.json() ) in another thread: Having trouble with Fetch in scripting block - #3 by kuovonne

Here’s a version that works:

let Stripe_API = 'YOUR_STRIPE_API_KEY';
let Stripe_URL = 'https://api.stripe.com/v1/customers/cus_MQGV6PEdpS1RWJ';
    
let options = {
    method: 'GET',
    headers: {
        'Authorization': 'Bearer ' + Stripe_API 
    }
};
console.log(options);

let response = await fetch(Stripe_URL, options);
let responseJson = response.json();
console.log(responseJson);