Update README.md for 1.hello-world. (#111)

Update README.md for 1.hello-world to reflect latest version.
This commit is contained in:
Artur Souza 2019-11-19 20:52:36 -08:00 committed by GitHub
parent dd2381197f
commit e2696774ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 4 deletions

View File

@ -51,10 +51,16 @@ app.post('/neworder', (req, res) => {
"Content-Type": "application/json"
}
}).then((response) => {
console.log((response.ok) ? "Successfully persisted state" : "Failed to persist state");
});
if (!response.ok) {
throw "Failed to persist state.";
}
res.status(200).send();
console.log("Successfully persisted state.");
res.status(200).send();
}).catch((error) => {
console.log(error);
res.status(500).send({message: error});
});
});
```
@ -79,9 +85,16 @@ We also expose a GET endpoint, `/order`:
app.get('/order', (_req, res) => {
fetch(`${stateUrl}/order`)
.then((response) => {
return response.json();
if (!response.ok) {
throw "Could not get state.";
}
return response.text();
}).then((orders) => {
res.send(orders);
}).catch((error) => {
console.log(error);
res.status(500).send({message: error});
});
});
```