Hi everyone. I am using SuperToken with nestjs, I ...
# general
a
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
hey @andrew1123 this is a JS releated error
i mean neither supertokens, nor nestjs
a
But I got no build time error from typeScript
r
You should make the isEmailSupported an arrow function
and same goes for signUp
a
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
@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
Yea. that works too!
But people generally prefer to use arrow functions since it's prettier.
2 Views