DNY client (3 – Creating a User)

On the client side, make sure we create the event handler for the submit button:

src/user/Signup.js

On the server side, make sure use cors.

To set up: npm i -S cors

app.js:

Now when you fill in the username, password, email, (like I did in the screenshot) you’ll see that the password is ‘compaq’ and does not have a number. Thus, you’ll get a bad request:

Click on the Network tab to see what this bad request is about. You’ll see the request, which is called signup. Click on signup.

In the response from the server, we see that the text tells us that we need a number in our password:

So change our password so that it has a number. This time, when you submit, you’ll see that the response to our request will be successful. When you analyze the response to our request, you’ll see that the json response will have a success message:

Go into your mLab account and you’ll see that our users have the information we just used to create a user:

Now, if you try to submit the same data for registration, the response from the server will tell you that the email you’re using to register already exists: