https://supertokens.com/ logo
Docs
Join the conversationJoin Discord
Channels
community
contributing
general
github-activity
info
introductions
new-releases
random
security
support-questions
welcome-0xdelusion
welcome-aj-ya
welcome-aleksandrc
welcome-alpinjs
welcome-amberlamps1
welcome-andrew-rodriguez
welcome-ankit-choudhary
welcome-anthony-stod-custodio
welcome-call-in
welcome-chwalbox
welcome-claybiokiller
welcome-co7e
welcome-cosmoecwsa
welcome-devdag
welcome-dinso
welcome-drebotelho
welcome-elio
welcome-ernest
welcome-foxbarrington
welcome-fromscratch
welcome-galto4ir
welcome-goetzum
welcome-hay-kot
welcome-himanshu-kukreja
welcome-hossambarakat
welcome-ichikawakazuto
welcome-jahir9991
welcome-jamesl
welcome-jerry123424
welcome-john-oliver
welcome-jonas-alexanderson
welcome-jxyz
welcome-kelvinwop
welcome-kraz
welcome-lancekey
welcome-leoo
welcome-lukeacollins
welcome-m-j-mon
welcome-malik-khoja
welcome-marco
welcome-mardadi
welcome-meshguy
welcome-metamorph
welcome-mike-tectu
welcome-mirzok
welcome-mozomig
welcome-naberyou66_
welcome-nacer
welcome-namratha
welcome-naveenkumar
welcome-nightlight
welcome-nischith
welcome-notankit
welcome-olawumi
welcome-pavan-kumar-reddy-n
welcome-pineappaul
welcome-poothebear
welcome-rick
welcome-samuel-qosenergy
welcome-samuelstroschein
welcome-shubhamgoel23
welcome-shubhamkaushal
welcome-sidebar
welcome-surajsli
welcome-suyash_
welcome-syntaxerror
welcome-tauno
welcome-tauno
welcome-tawnoz
welcome-teclali
welcome-tls
welcome-turbosepp
welcome-vikram_shadow
welcome-yann
Powered by Linen
support-questions
  • r

    rp

    04/26/2021, 4:09 AM
    What are you giving as the
    res
    object to the function?
  • d

    dleiva04

    04/26/2021, 4:09 AM
    just the
    res
  • d

    dleiva04

    04/26/2021, 4:09 AM
    message has been deleted
  • d

    dleiva04

    04/26/2021, 4:10 AM
    message has been deleted
  • r

    rp

    04/26/2021, 4:11 AM
    in the
    signIn
    function, you have to wait for
    createSession
    to return before doing
    res.json(u)
  • r

    rp

    04/26/2021, 4:11 AM
    since
    createSession
    is async
  • r

    rp

    04/26/2021, 4:14 AM
    so it should become:
    const createSession = async (res, userId) => {
      await Session.createNewSession(res, userId);
    }
    
    const signIn = (req, res) => {
      ...
      .signIn(email, password)
      .then(async (u) => {
         try {
           await createNewSession(res, u.id);
           res.json(u)
          } catch (err) {
            res.status(500).json(e)
          }
       });
    }
  • d

    dleiva04

    04/26/2021, 4:50 AM
    Ohh ok, thank you!
  • r

    rp

    04/26/2021, 4:50 AM
    did this solve the issue?
  • d

    dleiva04

    04/26/2021, 4:53 AM
    Im not getting the same eror
  • d

    dleiva04

    04/26/2021, 4:53 AM
    message has been deleted
  • r

    rp

    04/26/2021, 4:54 AM
    Can I see the whole error please?
  • d

    dleiva04

    04/26/2021, 4:54 AM
    message has been deleted
  • r

    rp

    04/26/2021, 4:55 AM
    Can I see your code again? It's probably the same error..
  • d

    dleiva04

    04/26/2021, 4:55 AM
    yeah
  • d

    dleiva04

    04/26/2021, 4:56 AM
    const createSession = async (res, userId) => {
        try {
            console.log(userId)
            await Session
                .createNewSession(res, userId)
                .then(token => {
                    console.log(token)
                }).catch(error => {
                    console.log(error)
                })
        } catch (error) {
            return error
        }
    }
  • d

    dleiva04

    04/26/2021, 4:56 AM
    const signIn = (req, res) => {
        const { email, password } = req.body
        try {
            ThirdPartyEmailPassword
                .signIn(email, password)
                .then(async u => {
                    await createSession(res, u.id)
                    res.json(u)
                }).catch(e => {
                    res.status(500).json(e)
                })
        } catch (error) {
            res.status(500).json(error)
        }
    }
  • r

    rp

    04/26/2021, 4:59 AM
    You should change it to the following please:
    const createSession = async (res, userId) => {
        try {
            console.log(userId)
            let session = await Session
                .createNewSession(res, userId);
            console.log(session);
        } catch (error) {
            console.log(error);
            throw error
        }
    }
    const signIn = (req, res) => {
        const { email, password } = req.body
            ThirdPartyEmailPassword
                .signIn(email, password)
                .then(async u => {
                    try {
                      await createSession(res, u.id)
                      res.json(u)
                    } catch (err) {
                      res.status(500).json(e.message)
                    }
                }).catch(error => {
                  res.status(500).json(error)
                })
    }
  • r

    rp

    04/26/2021, 5:05 AM
    @User we are working on an AWS lambda example which will make it easier to implement SuperTokens for you.
  • u

    user

    04/26/2021, 5:12 AM
    btw you dont have to to try catch inside the promise, if there is an exception inside promise, the promise is rejected automatically. The then should just look like
    .then(async u => {
                      await createSession(res, u.id)
                      res.json(u)
  • r

    rp

    04/26/2021, 5:13 AM
    True.
  • u

    user

    04/26/2021, 5:15 AM
    btw is there a doc page with all the possible api calls? or everything is made as premade recipes in the various npm packages? I'm trying to better understand if supertokens is what I need/want 🙂 (didnt look throgh whole doc yet)
  • r

    rp

    04/26/2021, 5:18 AM
    So the docs structure is as follows: - We have one docs per recipe (the type of auth you want to use). For example, if you want email password + social login, you should follow https://supertokens.io/docs/thirdpartyemailpassword/introduction - We have one docs per SDK (containing all the functions exposed by that SDK). These are only meant for reference in case the recipe docs are not enough. An example of is this our node SDK docs: https://supertokens.io/docs/nodejs/installation
  • r

    rp

    04/26/2021, 5:19 AM
    > or everything is made as premade recipes in the various npm packages It's one npm package for frontend, and one for backend. Within these, we have the various recipes.
  • u

    user

    04/26/2021, 5:24 AM
    ok great thanks for help
  • u

    user

    04/26/2021, 5:24 AM
    found what I searched for 😄
  • u

    user

    04/26/2021, 5:24 AM
    SuperTokens does not store those custom fields on successful signup.
  • r

    rp

    04/26/2021, 5:25 AM
    yea. We provide them to you post sign up and you can handle them yourself.
  • u

    user

    04/26/2021, 5:26 AM
    thats ok, just going through all of it to see how much is done for me 😄
  • r

    rp

    04/26/2021, 5:26 AM
    fair enough.
Powered by Linen
Title
r

rp

04/26/2021, 5:26 AM
fair enough.
View count: 1