How to fetch text from HTML URL using API

Hi,

I’m trying to fetch from https://iasvalley.com.my/ , which is our own website using the GET API tools. but the developer console returns the error

Access to fetch at ‘https://iasvalley.com.my/’ from origin ‘https://platform.appgyver.com’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

How do I workaround with this? I realise that the same error comes out if I were to fetch any kind of HTML URL

I tried using API test tools at https://reqbin.com/ and it works fine

Please help

Thank you!

Finally got it

The JavaScript logic is already in async mode

I could just use await and fetch() to get the .text() / .json() of the url

like this

const res = await fetch(“https://www.google.com”);
const content = await res.text()

1 Like