DEV Community

Cover image for REST API CALL
Ayush2810
Ayush2810

Posted on

REST API CALL

Can anybody help to do a REST call.
MY CODE

ERROR received is in attached image.

const header = new Headers();
header.append("Access-Control-Allow-Origin", "*")
header.append("cache-control","no-cache")
fetch("https://api.coinex.com/v1/market/list",{
headers : header,
rejectUnauthorized: false
}).then(res =>{
return res.json()
.then(r =>{
console.log(r)
})
})

Top comments (2)

Collapse
 
amansaxena001 profile image
Amansaxena001

This is happening because your browser is not allowing the response that server is sending. The problem might be headers are not added correctly to the request headers. Can you Share the screenshot of network tab? and see if request headers are properly set or not.

Collapse
 
ayush2810 profile image
Ayush2810

Never Mind, I solved it with the help of following URL - stackoverflow.com/questions/438716...

Use the Proxy URL