Indeed, the postman-echo.com test api returns some error message:
Access to fetch at 'https://postman-echo.com/get?action=12345' from origin 'https://ui.vision' has been blocked by CORS policy:
→ That api does not like to be called from within a website it seems?
Anyway, for other “normal” APIs the fetch method works well. For example, here is my simple script to get my current IP address via GET API call:
{
"Name": "GET API call",
"CreationDate": "2023-8-15",
"Commands": [
{
"Command": "open",
"Target": "https://ui.vision",
"Value": "",
"Description": "Open any website, \"executeScript\" runs inside it"
},
{
"Command": "executeScript",
"Target": "async function callmyAPI() {\n \nconst response = await fetch(\"https://api.ipify.org?format=json\");\n \nconst data = await response.json();\n \nresult = data[\"ip\"];\n \nreturn JSON.stringify(result);\n}\nreturn callmyAPI();",
"Value": "v",
"Description": "Call GET API"
},
{
"Command": "echo",
"Target": "My IP address is =${v}",
"Value": "blue",
"Description": ""
}
]
}
The executeScript JS code is:
async function callmyAPI() {
const response = await fetch("https://api.ipify.org?format=json");
const data = await response.json();
result = data["ip"];
return JSON.stringify(result);
}
return callmyAPI();