From 8296b3c02550b8965dad5f8f88883b867f02f907 Mon Sep 17 00:00:00 2001 From: Sarthak1231 <91138224+Sarthak1231@users.noreply.github.com> Date: Fri, 12 Jun 2026 00:06:19 +0530 Subject: [PATCH] Update add_put_request.md --- .../3_backend_and_frontend/add_put_request.md | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tasks/3_backend_and_frontend/add_put_request.md b/tasks/3_backend_and_frontend/add_put_request.md index 40046df..569953e 100644 --- a/tasks/3_backend_and_frontend/add_put_request.md +++ b/tasks/3_backend_and_frontend/add_put_request.md @@ -1,16 +1,19 @@ -# Add PUT Request To Lib +import axios from "axios"; +import { Goal } from "./types"; // adjust path if needed -- [ ] Add PUT request to update Goal - -```ts -// lib.ts - -export async function updateGoal(goalId: string, updatedGoal: Goal): Promise { +export async function updateGoal( + goalId: string, + updatedGoal: Goal +): Promise { try { - await axios.put(`${API_ROOT}/api/Goal/${goalId}`, updatedGoal) - return true + await axios.put( + `${API_ROOT}/api/Goal/${goalId}`, + updatedGoal + ); + + return true; } catch (error: any) { - return false + console.error("Failed to update goal:", error); + return false; } } -```