I am trying to register a user with credentials piped in from an external mobile app using json and wix-http-functions. The website and mobile app need to share user information, so that the two are virtually seamless. When a user registers on the mobile app, the app will send the website data and register the user on the website as well.
Here is the code I currently have, however my contacts and such are not being updated.
-Backend-
import { serverError, created } from ‘wix-http-functions’;
import wixUsers from ‘wix-users-backend’;
If you want to update a contact use the createContact() method found here. Syntax-wise the above code looks fine. Let me know if this is what you wanted or if it still does not work.
@mqumseya I am trying to send an email address, password and some additional information to my site’s backend using postman…
[
{
“newUser”: {
“email”: “test@fakemail.com”,
“password”: “password”,
“contactInfo”: {
“firstName”: “John”,
“lastName”: “Doe”,
“phone”: “1234567890”,
“customerNumber”: “000001”
}
}
}
]
I am getting a 500 error in response. I have waited and tried again, as suggested by one of the wix articles. Is this really a wix server error or am I not doing something right?
@jamesschulze It is not necessarily a problem with wix servers, it is most likely an authentication/verification issue or the url/function is misspelled.
Can I get the url to your site so that I can do some testing?
@jamesschulze As @mqumseya mention, it’s not necessarily a problem with Wix servers, in most of the cases it’s not (probably, they will fix the problem before you will notice).
In most of the cases, the 500 error response it because of unhandled error in your code. When an error is thrown, the code is never getting to the return statement so the server returns nothing.
To send the error to the client, wrap your code with try / catch and in the catch part, send a response with the error message to the client.
Also, I know you used **import** wixUsers **from** 'wix-users-backend'; but please double check it because if you import from `wix-users’ the an error will be thrown.
Did you manage to register a user with http function?
I’m facing the same issue recently and can’t get it done.
I recieve 200 from the server but the register() function does nothing.
Hope you succeded and will be able to give me some guidelines.
@mqumseya how would you solve the follow-on login() problem in this setup? Both the login() and the register() return a “sessionToken” that typically need to be applied in the frontend using wixUsers.applySessionToken() method, however on the mobile side this can obviously not be done. How can you log that user in that was created previously using the http-functions method?
I am having an issue with registering a user. We create new users when our customer orders one of our products from an external site. So I am creating a register function to register the user account. When I execute the code below I get a 500 error