https://supertokens.com/ logo
#general
Title
# general
a

andrew1123

04/22/2022, 11:37 AM
Hi everyone. I am using SuperToken with nestjs, I am trying out the api override feature to customise the signup flow. I have the auth module from the docs, I created auth.service inside the module. Inside the auth.service, I created a method called signUp and a private method isEmailSupported, then I inject the auth.service into supertokens.service and set the signUp function to the value of the signUpPOST key. When I trigger the signup, I got an error from nestjs, saying that "this.isEmailSupported is not a function". Is it a supertoken specific problem or nestjs problem?
r

rp

04/22/2022, 11:39 AM
hey @andrew1123 this is a JS releated error
i mean neither supertokens, nor nestjs
a

andrew1123

04/22/2022, 11:39 AM
But I got no build time error from typeScript
r

rp

04/22/2022, 11:39 AM
You should make the isEmailSupported an arrow function
and same goes for signUp
a

andrew1123

04/22/2022, 11:40 AM
Oh, thanks, I'll try
I worked! But why? I seldom see arrow function declaration in typescript class
Search for Main benefit: No binding of ‘this’
a

andrew1123

04/22/2022, 1:16 PM
@rp Thank you! Understood the concept, also found an alternative way to solve it. Changed the signUpPOST value to
Copy code
this.authService.signUp.bind(this.authService)
r

rp

04/22/2022, 1:17 PM
Yea. that works too!
But people generally prefer to use arrow functions since it's prettier.
2 Views