Using JavaScript to connect sense to get data and report error
When I use the API of the official website to retrieve the table data, an error is reported,as follows:
Error: unsupported certificate purpose at TLSSocket.onConnectSecure (_tls_wrap.js:1049:34) at TLSSocket.emit (events.js:182:13) at TLSSocket._finishInit (_tls_wrap.js:631:8) Emitted 'error' event at: at ClientRequest.req.on (D:\workspase\weixin_app\node_modules\ws\lib\websocket.js:554:15) at ClientRequest.emit (events.js:182:13) at TLSSocket.socketErrorListener (_http_client.js:391:9) at TLSSocket.emit (events.js:182:13) at emitErrorNT (internal/streams/destroy.js:82:8) at emitErrorAndCloseNT (internal/streams/destroy.js:50:3) at process._tickCallback (internal/process/next_tick.js:63:19)
Here is my code:
var certPath = path.join('D:','workspase','weixin_app','keys'); var certificates = { key: fs.readFileSync(path.resolve(certPath, 'client_key.pem')), cert: fs.readFileSync(path.resolve(certPath, 'client.pem')), root: fs.readFileSync(path.resolve(certPath, 'root.pem')) }; const ws = new WebSocket('wss://172.16.100.74:4747/app/', { ca: [certificates.root], cert: certificates.cert, key: certificates.key, headers: { 'X-Qlik-User': 'UserDirectory=internal; UserId=sa_engine' } }); ws.onopen = function (event) { // send some message }