Help

I need a DELAY method & setTimeout() is undefined (not found Window)

Topic Labels: Scripting extentions
29376 57
cancel
Showing results for 
Search instead for 
Did you mean: 
David_Koontz
6 - Interface Innovator
6 - Interface Innovator

Hey,

I’m a newbie with JavaScript so this might be obvious …

I need a delay(ms) method to slow down the script after 5 API calls (limit 5/min.). Problem is all the JavaScript help on the intertube points to the setTimeout() method of the Window object. But it appears that Window is not instantiated inside the Airtable code block, therefore, no setTimeout() method. What’s a good workaround for this?

What might I be missing - other methods?

Thanks
David

57 Replies 57

Yes @Bill.French I’ve checked and rechecked … same code! I can’t recreate the state of my system the other night when it was failing and I chased a rabbit down the wrong trail… but I swear it was not working… now it could be one of many reasons (maybe none the timeout method) cause I’m a newbie with embedding JS like this.

But now that it’s working I’m continuing my attempt to get stock quotes via 3rd party (Alpha Vantage http://alphavantage.co) - I’d like to know what interfaces I’d need to support to make my code a first rate Airtable block. (any info?)

Simple answer - Script Block is an infant, not even a toddler yet. Surprisingly, it runs very well despite it being only a few weeks old.

Thanks for the info. I don’t use an IDE.

I have seen wavy red underlines in other contexts for years (Word documents), and they usually mean that the grammar checker thinks the section has a grammar problem. Sometimes there really is a grammar problem, and sometimes there isn’t. When I know the grammar is correct, I ignore the wavy red underlines.

My code editor does not have a grammar checker, but it does color-code text according to a selected grammar, which helps in discovering some grammar problems.

In the Airtable scripting block, I assumed that the wavy red underlines were also a grammar/vocabulary checker. I find that Airtable editor’s grammar/vocabulary checker is so overzealous that it gets in my way. I do use it to check to make sure the grammar and vocabulary is correct, but I also feel free to ignore its suggestions.

I have not seen wavy red underlines directly indicating that a particular feature is unsupported. Rather I take it to simply mean that the grammar checker does not understand the section, which may or may not mean that the features lack support.

I’ve been very happy with Scripting block, and I’ve gotten a lot of enjoyment out of it. I’m not surprised at how well it runs–I expected that level of quality from Airtable.

LOL! I believe you. This is software.

Well, you need URLFetch() to pull that off, but “first rate” is a subjective question.

David_Koontz
6 - Interface Innovator
6 - Interface Innovator

Yes the Scripting Block does a really good job for being such a new feature. I AM AMAZED. I worked with it for hours and never had any issue. For a web app - this is unheard of reliability - not seen since Netware was turned off. Someone knows how to write some great code that recovers all it’s memory well.

How are you calling the other API? One of the APIs I use doesn’t allow you to pass your key through the URL and when I try to install https, it doesn’t seem to work.

David_Koontz
6 - Interface Innovator
6 - Interface Innovator

In the script (JavaScript code):

let info = await fetch(https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=${symbol}&apikey=${API_KEY});

But the format of the URL is API specific - this is for Alpha Ventures. You should read their docs/examples or call them.

Thanks for the info. This company doesn’t actually have API documentation which makes trying to find what to pass very frustrating. Their example shows “api-key” but it only works when using curl… I’ve reached out to their team and it seems like their knowledge of how it works is as good as their non-existent documentation.

Paste the CURL example here and I’ll bet we can transform the requirements into Airtable speak.