Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions task-1/delete.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
curl -X DELETE http://localhost:3000/users/11
2 changes: 2 additions & 0 deletions task-1/get.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
curl -X GET http://localhost:3000/users/11
4 changes: 4 additions & 0 deletions task-1/patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
curl -X PATCH http://localhost:3000/users/11 \
-H "Content-Type: application/json" \
-d '{"email":"johndoe@example.com"}'
4 changes: 4 additions & 0 deletions task-1/post.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
curl -X POST http://localhost:3000/users \
-H "Content-Type: application/json" \
-d '{"name":"John Doe","email":"john.doe@example.com","password":"secret123","role":"user","active":true,"department":"Engineering"}'
8 changes: 7 additions & 1 deletion task-2/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ const API_BASE_URL = 'https://api.nobelprize.org/2.1';
* @param {Function} onError - Callback for fetch errors
*/
export function fetchNobelPrizes(filters = {}, onSuccess, onError) {
let url = ''; // TODO Construct the full URL with query parameters;
let url = 'https://api.nobelprize.org/2.1/nobelPrizes?offset=10&limit=20&sort=desc'; // TODO Construct the full URL with query parameters;
if (filters.year && filters.year !== 'all') {
url += `&nobelPrizeYear=${filters.year}`;
}
if (filters.category && filters.category !== 'all'){
url += `&nobelPrizeCategory=${filters.category}`;
}
Comment on lines +19 to +24

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will work too, because filters.year will be undefined if the .year property does not exist, and undefined !== 'all. Some for .category.

Suggested change
if (filters.year && filters.year !== 'all') {
url += `&nobelPrizeYear=${filters.year}`;
}
if (filters.category && filters.category !== 'all'){
url += `&nobelPrizeCategory=${filters.category}`;
}
if (filters.year !== 'all') {
url += `&nobelPrizeYear=${filters.year}`;
}
if (filters.category !== 'all'){
url += `&nobelPrizeCategory=${filters.category}`;
}


fetchData(url, onSuccess, onError);
}