https://supertokens.com/ logo
Title
f

funk101

11/28/2022, 3:42 PM
Question about
response.session.mergeIntoAccessTokenPayload()
after overriding api
signInPOST
and getting a
response
I try to merge to access token payload but do not see the value when I
console.log()
the accessTokenPayload.
r

rp

11/28/2022, 3:59 PM
hey @funk101
can you please share some code snippet for what you are doing?
f

funk101

11/28/2022, 4:01 PM
signInPOST: async function (input) {
                if (originalImplementation.signInPOST === undefined) {
                  throw Error("Shouldn't come here");
                }
                try {
                  const response = await originalImplementation.signInPOST(
                    input
                  );
                  if (response.status === "OK") {
                    const currentAccessTokenPayload =
                      response.session.getAccessTokenPayload();
                    await response.session.mergeIntoAccessTokenPayload({
                      ...currentAccessTokenPayload,
                      message: "Hello World",
                    });
                    console.log("Payload: ", currentAccessTokenPayload);
                  }
                  return response;
                } catch (err) {
                  console.log("signInPOST: ", err);
                }
              },
should I see that payload where the console.log() is?
This is what I get ->
Payload:  {}
r

rp

11/28/2022, 4:08 PM
thats cause you have created the variable
currentAccessTokenPayload
before calling
mergeIntoAccessTokenPayload
..
f

funk101

11/28/2022, 4:14 PM
right I see that now, thanks