From a4f1ee55d6e16a710c718f16286a1c8835657b0f Mon Sep 17 00:00:00 2001 From: Jawad Al Bdiwi Date: Wed, 11 Mar 2026 14:17:07 +0100 Subject: [PATCH 1/2] assignment complete --- task-1/delete.sh | 4 ++++ task-1/get.sh | 3 +++ task-1/patch.sh | 7 +++++++ task-1/post.sh | 13 +++++++++++++ 4 files changed, 27 insertions(+) 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/task-1/delete.sh b/task-1/delete.sh new file mode 100644 index 0000000..4649f5d --- /dev/null +++ b/task-1/delete.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +curl -X DELETE http://localhost:3000/users/11 + diff --git a/task-1/get.sh b/task-1/get.sh new file mode 100644 index 0000000..db43b39 --- /dev/null +++ b/task-1/get.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +curl -X GET http://localhost:3000/users/11 diff --git a/task-1/patch.sh b/task-1/patch.sh new file mode 100644 index 0000000..0937b61 --- /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; charset=UTF-8" \ + -d '{ + "email": "johndoe@example.com" + }' diff --git a/task-1/post.sh b/task-1/post.sh new file mode 100644 index 0000000..db98c6e --- /dev/null +++ b/task-1/post.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +curl -X POST http://localhost:3000/users \ + -H "application/json; charset=UTF-8" \ + -d +'{ + "name": "John Doe", + "email": "john.doe@example.com", + "passowrd": "secret123" + "role": "user", + "active": true, + "department": "Engineering" +}' From 7988098f3fabc8e1ae4948f68eb8a7062d28adf2 Mon Sep 17 00:00:00 2001 From: Jawad Al Bdiwi Date: Wed, 11 Mar 2026 14:17:39 +0100 Subject: [PATCH 2/2] assignment complete --- task-2/services.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/task-2/services.js b/task-2/services.js index 2126969..1c215dc 100644 --- a/task-2/services.js +++ b/task-2/services.js @@ -1,8 +1,8 @@ // Nobel Prize API Documentation: https://www.nobelprize.org/about/developer-zone-2/ -import { fetchData } from './fetcher.js'; +import { fetchData } from "./fetcher.js"; -const API_BASE_URL = 'https://api.nobelprize.org/2.1'; +const API_BASE_URL = "https://api.nobelprize.org/2.1"; /** * Fetch Nobel Prizes with optional filters @@ -14,8 +14,24 @@ const API_BASE_URL = 'https://api.nobelprize.org/2.1'; * @param {Function} onSuccess - Callback for successful fetch * @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 = ""; + 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); + } + + url = `${API_BASE_URL}/nobelPrizes?${params.toString()}`; fetchData(url, onSuccess, onError); }