Skip to content

Commit

Permalink
fix request
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio1988 committed Dec 15, 2023
1 parent cb656b7 commit 20d8735
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dev:server": "nx run server:dev",
"lint": "nx run-many --target=lint --all",
"start": "node dist/packages/server/main.js",
"test": "NODE_ENV=development NX_ENABLE_MOCKS=1 nx run-many --target=dev --all",
"clear-cache": "nx clear-cache"
},
"volta": {
Expand Down
3 changes: 3 additions & 0 deletions packages/client/src/app/jobs/executeJobModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export const ExecuteJobModal = ({ closeModal, devices, jobId }: ExecuteJobModalP
async ({ deviceIds }: { deviceIds: string[] | number[] }) => {
const promise = fetch(`/api/job/execute/${jobId}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json', // Set the Content-Type header to application/json
},
body: JSON.stringify({ deviceIdsOrOrigins: deviceIds }),
}).then(async (response) => {
if (response.status !== 200) {
Expand Down
6 changes: 5 additions & 1 deletion packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,11 @@ const routes = async (fastifyInstance: FastifyInstance) => {
jobId: string;
}

fastifyInstance.post<{ Params: JobExecuteParams; Body: { deviceIdsOrOrigins?: string[] | number[] } }>(
interface DeviceIdsOrOriginsBody {
deviceIdsOrOrigins?: string[] | number[];
}

fastifyInstance.post<{ Params: JobExecuteParams; Body: DeviceIdsOrOriginsBody }>(
'/api/job/execute/:jobId/:deviceIdsOrOrigins?',
async (req, reply) => {
const { deviceIdsOrOrigins, jobId } = req.params;
Expand Down

0 comments on commit 20d8735

Please sign in to comment.