How to fetch text from HTML URL using API


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

Access to fetch at ‘’ from origin ‘’ 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 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(“”);
const content = await res.text()

1 Like