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

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

5 changes: 5 additions & 0 deletions task-1/delete.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

curl http://localhost:3000/users/11 \
--request DELETE \
--header 'Content-Type: application/json' \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Content-Type header specifies how the request body should be interpreted. However, the GET and DELETE methods do not have a request body. So, you can just ignore this request header. The API server just ignores it.

5 changes: 5 additions & 0 deletions task-1/get.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

curl http://localhost:3000/users/11 \
--request GET \
--header 'Content-Type: application/json' \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Content-Type not needed. No request body.

8 changes: 8 additions & 0 deletions task-1/patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

curl http://localhost:3000/users/11 \
--request PATCH \
--header 'Content-Type: application/json' \
--data '{
"email": "johndoe@example.com"
}'
13 changes: 13 additions & 0 deletions task-1/post.sh
Original file line number Diff line number Diff line change
@@ -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"
}'
22 changes: 19 additions & 3 deletions task-2/services.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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);
}