Oct 14, 2021 08:31 AM
Hello,
I need help fetching data.
I’m new to airtable and also don’t have much experience in scripting but I do have some code experience.
I’m trying to fetch Zipcodes from https://www.zipcodeapi.com/API
I can use one of the two:
This is the code I have that use the GET method (yes I know):
// @ts-nocheck
let response = await fetch(‘https://www.zipcodeapi.com/rest/js-APIKEY/radius.json/59718/30/mile’)
console.log(await radius.json());
I get:
### ERROR
ReferenceError: radius is not defined
at main on line 3
I did tried to add method, headers… all kind of thigs but with no luck. I know I’m doing it wrong.
Any help please?
Thank you very much
Ehud
Oct 14, 2021 09:00 AM
It doesn’t matter how good your code is - if the endpoint doesn’t resolve, the API call will fail.
Oct 14, 2021 09:03 AM
The api key is missing from your code :slightly_smiling_face:
It work when I use it as http get and not as JS code (from integromat and from adalo and from postman). But the zip code api company say it is possible. So I think its a problem with my code.
As I understand in Airtable this is the only way to do that?
Oct 14, 2021 09:04 AM
I don’t have ANY code - you need to share your code if you want to get precise answers.
Oct 14, 2021 09:06 AM
I just saw that the APIKEY reference in my code wasn’t show because it was in a
I change that.
But still it wont work without the key in the url.
There are demo option in the link I shared
Oct 14, 2021 09:15 AM
the issue is you last line: console.log(await radius.json());
should be: console.log(await response.json());
Oct 14, 2021 09:33 AM
Thank you, it is working now. I had one more problem that I needed to authorize airtableblocks.com also. not only airtable.com at the other side :slightly_smiling_face:
Oct 14, 2021 09:36 AM
now I want to make the zipcode and the distance dynamic.
its the 59718
and the 30
I have webhook at Airtable that get those dynamic fields from user input at Adalo.
How do I make my code recive those dynamic parameters from the webhook?
Thanks :blush: