How to send https get request on js and show it to the user.
OfirApps (0)

hello, im looking a long time for the answer and i cant find it anywere (How to send https get request on js and show it to the user.)

You are viewing a single comment. View All
ruiwenge2 (1182)

you can use the fetch API:

fetch("URL", {
  method:"GET"
}).then(response => response.text()).then(response => alert(response));

replace URL with the url you want to get the request from. you can do whatever you want with the response. I hope this helps!

OfirApps (0)

@ruiwenge2 how do i show it to the user?

ruiwenge2 (1182)

@OfirApps in the code i showed you, i used alert, which is like a popup. you can do whatever you want with the response.

ruiwenge2 (1182)

@OfirApps pls mark as correct if it helped!

OfirApps (0)

@ruiwenge2 i checked and i cant send https:// requests

ruiwenge2 (1182)

@OfirApps thats because the CORS policy doesn't allow you to fetch from another website. you can only fetch from your own website. if you want to fetch from another website, you have to change the method to no-cors, but you won't get a response.