I want to throw custom error here : Incase the use...
# general
k
I want to throw custom error here : Incase the user enters wrong number which api to override in node js
r
hey @krrishan
by throw you mean you want to send a 400 error to the frontend? Or just change the message in the above response to something else?>
k
both Actually I have my own exception handler method
r
right, so then override the createCodePOST API
and do your check for phone number there, and throw a JS error or somehting which is propagated to your own error handler
k
It is not even reaching that method :
I added a console log but not printing anything even before create code function is called , it fails
as I am passing wrong phone number
it must run before createCode api : auth/signinup/code
r
it should
how have you added this? Show me the full recipe init
k
you mean recipeList ?
tried overriding signinUp aswell , but it not even entering that
r
are you sure this config is being loaded?
i think the issue is with how you have written the functions
see our docs
k
yes rest everything is working fine I have overriden other methods too
r
it should be:
Copy code
override: {
            apis: (originalImplementation) => {
              return {
                ...originalImplementation,
                signInUpPOST: async (...) => {...},
                consumeCodePOST: async (...) => {...},
                
              };
            },
not the way you have where you have done
async signInUpPOST(..) {..}
k
the error of validating phone number is returned even before the createCode method is called If I know that method then it can be overridden
r
as i said.. the override should be called. Please see our docs for how to override it
and try the method i mentioned above.
Instead of how you have defined it
k
It is same thing sir
figured out It was this method
r
right. Okay!
i didnt realise you had provided an impl for this method too
k
it wasn't provided initially added now
r
ok ok
3 Views