-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
31 lines (28 loc) · 767 Bytes
/
example.js
File metadata and controls
31 lines (28 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const email = 'johndoes@gmail.com';
const password = 'blablabla';
fetch('http://localhost:4242/register', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
email,
password
}),
}).then((response) => response.json())
.then((responseJson) => {
if(responseJson.error){
let error = "";
responseJson.error.forEach(err => {
error = `${error}\n${err}`;
})
console.log(error);
//Show the error with the client.
}
//if no error just log the client
console.log(responseJson);
})
.catch((error) => {
console.log(error);
})