Websocket connection returns CORS error

rameshslm05
Hi.

I would like to fetch live market data using kietconnect api.

I tried using Javascript web socket that were mentioned in kiteconnect api docs page. That returns connection failed.

Tried using VUEJS, It returns CORS error.


MY CODE:

var KiteTicker = require('kiteconnect').KiteTicker
var ticker = new KiteTicker({
api_key: '**********',
access_token: '***********'
})
ticker.connect()
ticker.on('ticks', onTicks)
ticker.on('connect', subscribe)
function onTicks (ticks) {
console.log('Ticks', ticks)
}
function subscribe () {
var items = [738561]
ticker.subscribe(items)
ticker.setMode(ticker.modeFull, items)
}



Response:

ccess to fetch at 'https://ws.kite.trade/?api_key=********&access_token=***********&uid=*******' 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.
Sign In or Register to comment.