diff --git a/package-lock.json b/package-lock.json index 020596f..837218f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "core-assignment-week-10", + "name": "core-assignment-week-9", "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "core-assignment-week-10", + "name": "core-assignment-week-9", "version": "1.0.0", "license": "ISC", "dependencies": { diff --git a/task-1/delete.sh b/task-1/delete.sh new file mode 100644 index 0000000..78351e0 --- /dev/null +++ b/task-1/delete.sh @@ -0,0 +1,2 @@ +curl http://localhost:3000/users/11 \ +--request DELETE diff --git a/task-1/get.sh b/task-1/get.sh new file mode 100644 index 0000000..6432baa --- /dev/null +++ b/task-1/get.sh @@ -0,0 +1 @@ +curl http://localhost:3000/users/11 diff --git a/task-1/patch.sh b/task-1/patch.sh new file mode 100644 index 0000000..a7012c8 --- /dev/null +++ b/task-1/patch.sh @@ -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" +}' diff --git a/task-1/post.sh b/task-1/post.sh new file mode 100644 index 0000000..29809f0 --- /dev/null +++ b/task-1/post.sh @@ -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" + }' diff --git a/task-2/fetcher.js b/task-2/fetcher.js index 4fcd7e5..ddd7bd5 100644 --- a/task-2/fetcher.js +++ b/task-2/fetcher.js @@ -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) => { diff --git a/task-2/services.js b/task-2/services.js index 2126969..60be8e0 100644 --- a/task-2/services.js +++ b/task-2/services.js @@ -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); }