ewelink-api
ewelink-api copied to clipboard
cant run on local node express
i'm trying to work with ewelink-api, I made this very basic express application:
const express = require('express');
const ewelink = require('ewelink-api');
const app = express();
const port = 3000;
app.get('/', async (req, res) => {
const connection = new ewelink({
email: '[email protected]',
password: 'xxx',
region: 'eu',
});
try {
const auth = await connection.getCredentials()
console.log(auth)
} catch (error) {
console.log(error)
}
});
app.listen(port, () => console.log(`Hello world app listening on port ${port}!`))
when i run it i have this error in console:
PS C:\Users\xxx\VScodeProjects\prova-node> node index.js
Hello world app listening on port 3000!
FetchError: request to https://eu-api.coolkit.cc:8080/api/user/login failed, reason: write EPROTO 17084:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:
at ClientRequest.<anonymous> (C:\Users\xxx\VScodeProjects\prova-node\node_modules\node-fetch\lib\index.js:1491:11)
at ClientRequest.emit (events.js:400:28)
at TLSSocket.socketErrorListener (_http_client.js:475:9)
at TLSSocket.emit (events.js:400:28)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
type: 'system',
errno: 'EPROTO',
code: 'EPROTO'
}
someone could help me? is there a guide to make a server or a client working with these api? thank you
Your code looks good, I used the same code, just changing the credentials and it works OK. I think you may be having a network issue, try using a VPN or a different internet connection. Seems here is something in the middle messing up the encryption.
Good luck !