<@498057949541826571> Hey there. Is there way to ...
# general
p
@rp_st Hey there. Is there way to pass data from front-end to backend when thirdparty tries to sign up.
r
hey @porcx yea, you can do this via the pre API hook feature we have for the signinup API call when the provider redirects you back to your app.
search in our docs for pre api hook
p
@rp_st i went through the documentation but got me confused. Here is what i wanted . This is what i am using in front end
Copy code
import ThirdPartyEmailPassword from "supertokens-web-js/recipe/thirdpartyemailpassword";
  await ThirdPartyEmailPassword.thirdPartySignInAndUp({}) {
code...
}
And in api
Copy code
thirdPartySignInUpPOST: async (input) => {code...}
Now i want some thing like in frontend
Copy code
await ThirdPartyEmailPassword.thirdPartySignInAndUp({position: 1})
and want to use that position data in backend in
Copy code
thirdPartySignInUpPOST: async (input) => {code...}
r
yea so when calling thirdPartySignInAndUp on the forntend, you can use the pre api hook option in that to modify the request body to add your custom prop
then on the backend, you can get the request object using input.options.request
and read the custom prop from it
p
@rp_st I can do this right ?
Copy code
await ThirdPartyEmailPassword.thirdPartySignInAndUp({
    options: {
      preAPIHook: async (input) => {
        console.log(input);
        let url = input.url;
        let requestInit = input.requestInit;
        let userContext = {
          classCode: classroomCode
        }

        // TODO: add your code here

        return { url, requestInit, userContext };
      },
    },
  })
but how do i use classcode in api
r
nope. you have to modify the requestInit.body
p
Yup thanks. Just curious about userContext. Thanks though
r
yea.. userContext is isolated to the frontend and backend. It's not shared across them. Not yet anyway
6 Views