Skip to content

Commit e269677

Browse files
authored
Update README.md for 1.hello-world. (#111)
Update README.md for 1.hello-world to reflect latest version.
1 parent dd23811 commit e269677

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

1.hello-world/README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,16 @@ app.post('/neworder', (req, res) => {
5151
"Content-Type": "application/json"
5252
}
5353
}).then((response) => {
54-
console.log((response.ok) ? "Successfully persisted state" : "Failed to persist state");
55-
});
54+
if (!response.ok) {
55+
throw "Failed to persist state.";
56+
}
5657

57-
res.status(200).send();
58+
console.log("Successfully persisted state.");
59+
res.status(200).send();
60+
}).catch((error) => {
61+
console.log(error);
62+
res.status(500).send({message: error});
63+
});
5864
});
5965
```
6066

@@ -79,9 +85,16 @@ We also expose a GET endpoint, `/order`:
7985
app.get('/order', (_req, res) => {
8086
fetch(`${stateUrl}/order`)
8187
.then((response) => {
82-
return response.json();
88+
if (!response.ok) {
89+
throw "Could not get state.";
90+
}
91+
92+
return response.text();
8393
}).then((orders) => {
8494
res.send(orders);
95+
}).catch((error) => {
96+
console.log(error);
97+
res.status(500).send({message: error});
8598
});
8699
});
87100
```

0 commit comments

Comments
 (0)