From bc5b92a6f389c7d67116ce66c12a9c6d74786365 Mon Sep 17 00:00:00 2001 From: otobongfp Date: Sun, 16 Jun 2024 03:42:55 +0100 Subject: [PATCH] Fix: Params of type string not assignable to type number --- server/save-course.route.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/server/save-course.route.ts b/server/save-course.route.ts index 503b3ed9..c8271997 100644 --- a/server/save-course.route.ts +++ b/server/save-course.route.ts @@ -1,18 +1,15 @@ -import {Request, Response} from 'express'; -import {findCourseById} from '../src/db-data'; - +import { Request, Response } from "express"; +import { findCourseById } from "../src/db-data"; export function saveCourse(req: Request, res: Response) { + const id = parseInt(req.params["id"]), + changes = req.body; - const id = req.params["id"], - changes = req.body; - - console.log("Saving course", id, JSON.stringify(changes)); - - const course = findCourseById(id); + console.log("Saving course", id, JSON.stringify(changes)); - course.description = changes.description; + const course = findCourseById(id); - res.status(200).json(course); + course.description = changes.description; + res.status(200).json(course); }