Skip to content

Commit af5f18e

Browse files
Use Node suggested method of returning response code instead of deprecated method
Signed-off-by: Nasir Pauldon-Collins <nasir.pauldon-collins@ibm.com>
1 parent dbc83ed commit af5f18e

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

network-test-app/app.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,13 @@ app.get("/", async (request, response) => {
4343
result = await client.query("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE';");
4444
console.log(result)
4545
await client.end()
46-
response.statusCode = 200;
47-
response.send("Successfully connected to postgres instance");
46+
response.status(200).send("Successfully connected to postgres instance");
4847
} catch (err) {
4948
console.error("Failed to connect to PostgreSQL instance", err);
50-
response.statusCode = 500;
51-
response.send("Could not connect to postgres instance:", err);
49+
response.status(500).send("Could not connect to postgres instance:", err);
5250
}
5351
} else {
54-
response.statusCode = 500;
55-
response.send("Could not connect to postgres instance: no postgres instance configured");
52+
response.status(500).send("Could not connect to postgres instance: no postgres instance configured");
5653
}
5754

5855

0 commit comments

Comments
 (0)