0

MY CODE :-

fetch('https://www.nseindia.com/api/option-chain-indices?symbol=NIFTY')
.then((response) => response.json())
.then((data) => console.log(data))
.catch(err => console.log(err))

Error

I am getting this error while calling the api , I also tried to do like

 
fetch('https://www.nseindia.com/api/option-chain-indices?symbol=NIFTY',
{
     mode: 'no-cors'
})
.then((response) => response.json())
.then((data) => console.log(data))
.catch(err => console.log(err))

by using this I am not getting the data.

another way I tried like

fetch('https://www.nseindia.com/api/option-chain-indices?symbol=NIFTY',
{  
    method: 'GET',
    headers: {
        authority: 'www.nseindia.com',
        dnt: '1',
        accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
        'accept-encoding': 'gzip, deflate, br',
        'accept-language': 'en-IN,en;q=0.9,en-GB;q=0.8,en-US;q=0.7,hi;q=0.6,mr;q=0.5',
        'cache-control': 'no-cache',
        'Accept-Encoding': 'gzip, deflate, br',
        'Accept-Language': 'en-US,en;q=0.9,hi;q=0.8',
        'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36'

        
    },
})
.then(data => console.log(data))
.catch(err => console.log(`ERROR: ${err}`))

This also not please help me to fetch json data from 'https://www.nseindia.com/api/option-chain-indices?symbol=NIFTY'

VLAZ
  • 26,331
  • 9
  • 49
  • 67

0 Answers0