Skip to main content
Solved

Using fetch() in a scripting extension


MrLuke
Forum|alt.badge.img+7

Hello

I've creating a function to act as a rudimentary web scraper to grab some meta data like the page title, description etc using the `fetch()` api. 

In an automation, this works perfectly as expected. But in a scripting extension, my `try...catch` throws an error message of "Failed to fetch".

Are there some restrictions/limitations between automation scripts and extension scripts when it comes to using `fetch()` ?

Best answer by AlliAlosa

In the extension, try replacing "fetch()" with "remoteFetchAsync()". This method only works in extension scripts whereas "fetch" works in automation scripts.

 

View original

2 replies

Forum|alt.badge.img+19
  • Inspiring
  • 382 replies
  • Answer
  • May 6, 2024

In the extension, try replacing "fetch()" with "remoteFetchAsync()". This method only works in extension scripts whereas "fetch" works in automation scripts.

 


MrLuke
Forum|alt.badge.img+7
  • Author
  • Inspiring
  • 18 replies
  • May 6, 2024
AlliAlosa wrote:

In the extension, try replacing "fetch()" with "remoteFetchAsync()". This method only works in extension scripts whereas "fetch" works in automation scripts.

 


Thanks that's fixed it! So simple 🤦


Reply