diff --git a/package-lock.json b/package-lock.json index 020596f..1dee487 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": { @@ -1810,7 +1810,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -2226,7 +2225,6 @@ "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", diff --git a/task-1/delete.sh b/task-1/delete.sh new file mode 100644 index 0000000..770466e --- /dev/null +++ b/task-1/delete.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +curl http://localhost:3000/users/11 \ + --request DELETE \ + --header 'Content-Type: application/json' \ \ No newline at end of file diff --git a/task-1/get.sh b/task-1/get.sh new file mode 100644 index 0000000..f7a4bbe --- /dev/null +++ b/task-1/get.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +curl http://localhost:3000/users/11 \ + --request GET \ + --header 'Content-Type: application/json' \ diff --git a/task-1/patch.sh b/task-1/patch.sh new file mode 100644 index 0000000..4930eff --- /dev/null +++ b/task-1/patch.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +curl http://localhost:3000/users/11 \ + --request PATCH \ + --header 'Content-Type: application/json' \ + --data '{ + "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..b474f07 --- /dev/null +++ b/task-1/post.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +curl http://localhost:3000/users \ + --request POST \ + --header 'Content-Type: application/json' \ + --data '{ + "name": "John Doe", + "email": "john.doe@example.com", + "password": "secret123", + "role": "user", + "active": true, + "department": "Engineering" + }' \ No newline at end of file diff --git a/task-2/services.js b/task-2/services.js index 2126969..20bc847 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 @@ -15,7 +15,23 @@ 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; + const params = new URLSearchParams({ + offset: filters.offset, + limit: filters.limit, + sort: "desc", + }); + // console.log(params) + 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()}`; + + console.log(url); fetchData(url, onSuccess, onError); }