Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions tasks/3_backend_and_frontend/add_put_request.md
Original file line number Diff line number Diff line change
@@ -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<boolean> {
export async function updateGoal(
goalId: string,
updatedGoal: Goal
): Promise<boolean> {
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;
}
}
```