From a2aafc46cc2cbd1f289a354e27e8324bb14288fc Mon Sep 17 00:00:00 2001 From: baraah Date: Tue, 10 Mar 2026 23:15:41 +0100 Subject: [PATCH 1/2] task 1 completed --- package-lock.json | 4 ++-- task-1/delete.sh | 3 +++ task-1/get.sh | 3 +++ task-1/patch.sh | 7 +++++++ task-1/post.sh | 13 +++++++++++++ 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 task-1/delete.sh create mode 100644 task-1/get.sh create mode 100644 task-1/patch.sh create mode 100644 task-1/post.sh 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..bc99701 --- /dev/null +++ b/task-1/delete.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +curl -X DELETE http://localhost:3000/users/11 \ No newline at end of file diff --git a/task-1/get.sh b/task-1/get.sh new file mode 100644 index 0000000..cb6c155 --- /dev/null +++ b/task-1/get.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +curl http://localhost:3000/users/11 \ No newline at end of file diff --git a/task-1/patch.sh b/task-1/patch.sh new file mode 100644 index 0000000..052ccaf --- /dev/null +++ b/task-1/patch.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +curl -X PATCH http://localhost:3000/users/11 \ +-H "Content-Type: application/json" \ +-d '{ + "email": "johndoe@example.com" +}' \ No newline at end of file diff --git a/task-1/post.sh b/task-1/post.sh new file mode 100644 index 0000000..2e5cc85 --- /dev/null +++ b/task-1/post.sh @@ -0,0 +1,13 @@ +#!/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" +}' + From 32da32a8262514fc0f9c81175bc3539f50191473 Mon Sep 17 00:00:00 2001 From: baraah Date: Wed, 11 Mar 2026 02:18:00 +0100 Subject: [PATCH 2/2] task 2 completed --- task-2/services.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/task-2/services.js b/task-2/services.js index 2126969..9938893 100644 --- a/task-2/services.js +++ b/task-2/services.js @@ -15,7 +15,20 @@ 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 = ''; // TODO Construct the full URL with query parameters; + const params = new URLSearchParams(); + + params.append('offset', filters.offset); + params.append('limit', filters.limit); + params.append('sort', 'desc'); + + if (filters.year !== 'all') { + params.append('nobelPrizeYear', filters.year); +} +if (filters.category !== 'all') { + params.append('nobelPrizeCategory', filters.category); +} +const url = `${API_BASE_URL}/nobelPrizes?${params.toString()}` fetchData(url, onSuccess, onError); }