skirda-backend/api/CustomerById/index.js
2022-08-24 15:08:22 +03:00

16 lines
511 B
JavaScript

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
};
}