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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions task-1/delete.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
curl http://localhost:3000/users/11 \
--request DELETE
1 change: 1 addition & 0 deletions task-1/get.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
curl http://localhost:3000/users/11
6 changes: 6 additions & 0 deletions task-1/patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
curl http://localhost:3000/users/11 \
--request PATCH \
--header "Content-Type: application/json; charset=UTF-8" \
--data '{
"email": "johndoe@example.com"
}'
11 changes: 11 additions & 0 deletions task-1/post.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
curl http://localhost:3000/users \
--request POST \
--header "Content-Type: application/json; charset=UTF-8" \
--data '{
"name": "John Doe",
"email": "john.doe@example.com",
"password": "secret123",
"role": "user",
"active": true,
"department": "Engineering"
}'
1 change: 1 addition & 0 deletions task-2/fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @param {Function} onSuccess Called with data for successful fetch
* @param {Function} onError Called with an Error object for fetch errors
*/

export function fetchData(url, onSuccess, onError) {
fetch(url)
.then((response) => {
Expand Down
14 changes: 12 additions & 2 deletions task-2/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ 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';
const params = new URLSearchParams();
params.set('offset', filters.offset);
params.set('limit', filters.limit);
params.set('sort', 'desc');
if(filters.year !== "all"){
params.set('nobelPrizeYear', filters.year);
}
if(filters.category !== "all"){
params.set('nobelPrizeCategory', filters.category);
}
url = `${url}?${params.toString()}`;
fetchData(url, onSuccess, onError);
}