From 45ce3e37a1bc44b61a82d5d87adb755737f44c72 Mon Sep 17 00:00:00 2001 From: Hui Miao Date: Tue, 30 Apr 2024 16:07:31 +0800 Subject: [PATCH] refactor: update repairs function (#11519) --- .../src/functions/repairs.js | 9 +++++---- .../src/functions/repairs.ts | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/templates/js/copilot-gpt-from-scratch-plugin/src/functions/repairs.js b/templates/js/copilot-gpt-from-scratch-plugin/src/functions/repairs.js index cc779b85fc..00279139f3 100644 --- a/templates/js/copilot-gpt-from-scratch-plugin/src/functions/repairs.js +++ b/templates/js/copilot-gpt-from-scratch-plugin/src/functions/repairs.js @@ -12,11 +12,15 @@ const { app } = require("@azure/functions"); */ async function repairs(req, context) { context.log("HTTP trigger function processed a request."); + + // Get the repair records from the data.json file. + const repairRecords = require("../repairsData.json"); + // Initialize response. const res = { status: 200, jsonBody: { - results: [], + results: repairRecords, }, }; @@ -28,9 +32,6 @@ async function repairs(req, context) { return res; } - // Get the repair records from the data.json file. - const repairRecords = require("../repairsData.json"); - // Filter the repair records by the assignedTo query parameter. const repairs = repairRecords.filter((item) => { const query = assignedTo.trim().toLowerCase(); diff --git a/templates/ts/copilot-gpt-from-scratch-plugin/src/functions/repairs.ts b/templates/ts/copilot-gpt-from-scratch-plugin/src/functions/repairs.ts index 95e94d9bc4..fc81dfd57a 100644 --- a/templates/ts/copilot-gpt-from-scratch-plugin/src/functions/repairs.ts +++ b/templates/ts/copilot-gpt-from-scratch-plugin/src/functions/repairs.ts @@ -24,7 +24,7 @@ export async function repairs( const res: HttpResponseInit = { status: 200, jsonBody: { - results: [], + results: repairRecords, }, };