Skip to main content

Airtable Scripting not parsing Stripe API response

  • September 13, 2022
  • 1 reply
  • 22 views

Forum|alt.badge.img+4

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.

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

Forum|alt.badge.img+4
  • Author
  • New Participant
  • 2 replies
  • September 13, 2022

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);