Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    need urgent help

    Bugs
    0
    6
    29
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      test123 last edited by

      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)

      M 2 Replies Last reply Reply Quote 0
      • T
        test123 last edited by

        We are using generating new TOTP every time while connecting to your server

        1 Reply Last reply Reply Quote 0
        • M
          Moderator_2 @test123 last edited by

          Hi @test123

          Apologies for delayed response.
          We are checking on this. will update you as soon as possible.

          Thanks & Regards,
          SmartAPI team

          1 Reply Last reply Reply Quote 0
          • M
            Moderator_2 @test123 last edited by

            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

            1 Reply Last reply Reply Quote 0
            • A
              aryan7t7 last edited by

              My smart api is can't be on

              M 1 Reply Last reply Reply Quote 1
              • M
                Moderator_2 @aryan7t7 last edited by

                Hi @aryan7t7

                Can u please elaborate on the query for us?

                Thanks & Regards,
                SmartAPI team

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post