Skip to content
This repository was archived by the owner on Dec 5, 2023. It is now read-only.

Commit 7adeebc

Browse files
Merge pull request #80 from microservices-demo/status-code-check
Check status code for explicit 500
2 parents 62d2a17 + 1c86ced commit 7adeebc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

api/orders/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
async.waterfall([
5959
function (callback) {
6060
request(endpoints.customersUrl + "/" + custId, function (error, response, body) {
61-
if (error || response.status_code === "500") {
61+
if (error || body.status_code === 500) {
6262
callback(error);
6363
return;
6464
}
@@ -87,7 +87,7 @@
8787
}
8888
console.log("Received response: " + JSON.stringify(body));
8989
var jsonBody = JSON.parse(body);
90-
if (jsonBody._embedded.address[0] != null) {
90+
if (jsonBody.status_code !== 500 && jsonBody._embedded.address[0] != null) {
9191
order.address = jsonBody._embedded.address[0]._links.self.href;
9292
}
9393
callback();
@@ -102,7 +102,7 @@
102102
}
103103
console.log("Received response: " + JSON.stringify(body));
104104
var jsonBody = JSON.parse(body);
105-
if (jsonBody._embedded.card[0] != null) {
105+
if (jsonBody.status_code !== 500 && jsonBody._embedded.card[0] != null) {
106106
order.card = jsonBody._embedded.card[0]._links.self.href;
107107
}
108108
callback();

0 commit comments

Comments
 (0)