Simply put, I am trying to fetch the html content from url "http://anovamoeda.oinvestidordesucesso.com/IS/nmREPORT.asp?NM=2"
from inside the Script Labs environment, when running through Excel. A simple fetch(url)
returns this enigmatic error message:
TypeError {}
description: "Failed to fetch"
message: "Failed to fetch"
number: -2147418113
▶__proto__: TypeError
▶constructor: function TypeError()
message: ""
name: "TypeError"
▶toString: function toString()
▶__proto__: Error
I could figure out that this is a network error (the promise returns rejected), which seems weird because I did also try to fetch JSON from an API and it worked fine (for instance, https://api.binance.com/sapi/v1/system/status
for those willing to try). First I thought it might be due to my url having html content, not JSON, but it is not like it cannot parse the information, it doesn't even get information to try. I tried to add a parameter to the fetch call passing {headers: {'Content-Type': 'text/html'}}
, but that didn't work. (Also, I'm a noob in JS.)
But I could fetch the information from inside Google Scripts, using their own UrlFetchApp API with a simple call to that fetch method.
Happy with any help as I could not find any.
You don't show enough code so I am not sure what you are doing. That URL does not return json: it is an html document. if you want the text of the html document try this: