Skip to main content
Solved

Using fetch() in a scripting extension

  • May 6, 2024 10:51 AM UTC
  • 2 replies
  • 196 views

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
This topic has been closed for replies.

2 replies

Forum|alt.badge.img+19
  • Inspiring
  • Answer
  • May 6, 2024 11:17 AM UTC

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
  • May 6, 2024 11:48 AM UTC

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 🤦