January 2020
Intermediate to advanced
530 pages
11h 11m
English
The /customerinfo endpoint takes the userID as the request parameter and returns a response object, with the customer details matching the user ID, after fetching them from the bank database.
The service fetches the user ID from the request body. It then uses the pg client object to run a SELECT query on the customers table in the banka database, as follows:
var userId=request.body.userId;client.query('SELECT name,address,account,balance from customers where user_id = $1', [userId], (error, results)=> {
On the response from the pg client, we check for error responses. In the case of no errors, the customer's name, address, account, and current balance are added to the json response object and sent ...
Read now
Unlock full access