need urgent help
-
Dear Team,
Why jwt token failing very frequently? In Node JS. We are using Library of Smart API.
self.setAccessToken(response.data.jwtToken);
^TypeError: Cannot read properties of undefined (reading 'jwtToken')
at /var/www/html/Github/ridhhi-sidhhi/node_modules/smartapi-javascript/lib/smartapi-connect.js:178:40
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) -
-
My smart api is can't be on
-
Hi @test123
Kindly use the below snippet to resolve the issue.
const PlaceOrder = async (
{ apikey, user_id, totp_secret, password,tradingsymbol,Qty,transactiontype,symboltoken }) => {
try {
const token = totp(totp_secret);
let smart_api = new SmartAPI({
api_key: apikey,
});let data = await smart_api.generateSession(user_id, password, token); if(data.status){ let userData = data.data; // user can check if the jwtToken available if(userData && userData.jwtToken){ let placeOrderData = await smart_api.placeOrder({ "variety": "NORMAL", "tradingsymbol": tradingsymbol, "symboltoken": symboltoken, "transactiontype": transactiontype, "exchange": "NFO", "ordertype": "MARKET", "producttype": "CARRYFORWARD", "duration": "DAY", "price": "0", "squareoff": "0", "stoploss": "0", "quantity": Qty }) console.log(placeOrderData); } }
}
catch (err) {
console.log(err.message);
return {}
}
};Thanks & Regards,
SmartAPI team -
Hi @test123
Apologies for delayed response.
We are checking on this. will update you as soon as possible.Thanks & Regards,
SmartAPI team -
We are using generating new TOTP every time while connecting to your server