skirda-backend/api/CustomerById/index.js

16 lines
511 B
JavaScript
Raw Normal View History

2022-08-24 12:08:22 +00:00
const customers = require('../data/customers.json');
module.exports = async function (context, req) {
const { id } = context.bindingData;
let customerId = +id;
let selectedCustomer = customers.find(customer => customer.id === customerId);
let response = selectedCustomer ? selectedCustomer : null;
context.res = {
// status: 200, /* Defaults to 200 */
headers: {
'Content-Type': 'application/json'
},
body: response
};
}