@rp_st I'm using passwordless recipe, i want to send another field value say 'role' from frontend to backend while submiting the OTP. I want that value to assign roles in supertokens
r
rp_st
04/05/2023, 6:51 AM
You can use the pre API hook on the frontend to set the custom attribute to the consume code API, and then read that on the backend by overriding the consumeCode API
n
Namratha
04/05/2023, 11:48 AM
Passwordless.init({
contactMethod: "EMAIL_OR_PHONE",
preAPIHook: async (context) => {
let url = context.url;
let requestInit = context.requestInit;
let action = context.action;
if (action === "PASSWORDLESS_CONSUME_CODE") {
context.userContext= {
role: "client"
}
}
return {
requestInit, url
};
}
}),
Namratha
04/05/2023, 12:01 PM
can i get an example for how to pass custom data from frontend pls?