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