Last active
July 15, 2023 06:22
-
-
Save NayabSiddiqui/231ffdf27d8cf510582061585c76eba0 to your computer and use it in GitHub Desktop.
Arguments Object: for "Summary and Results" paper summary.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type BearerToken = string; | |
type Page = { | |
pageNumber: number; | |
pageSize: number; | |
sort: Sort; | |
}; | |
type SortDirection = 'asc' | 'desc'; | |
type Sort = { | |
sortByField: string; | |
sortDirection: SortDirection; | |
}; | |
const getPosts = (token: BearerToken, page: Page) => { | |
const { pageNumber, pageSize, sort } = page; | |
const { sortByField, sortDirection } = sort; | |
return fetch( | |
`https://myblog.com/posts?pageSize=${pageSize}&pageNumber=${pageNumber} | |
&sortBy=${sortByField}&sortDirection=${sortDirection}}`, | |
{ | |
method: 'GET', | |
headers: { | |
'Content-Type': 'application/json', | |
Authorisation: `bearer ${token}`, | |
}, | |
} | |
) | |
.then((response) => response.json()) | |
.then((data) => data.posts) | |
.catch((error) => console.log(error)); | |
}; | |
const getComments = (token: BearerToken, postId: string, page: Page) => { | |
const { pageNumber, pageSize, sort } = page; | |
const { sortByField, sortDirection } = sort; | |
return fetch( | |
`https://myblog.com/posts/${postId}/comments?pageSize=${pageSize}&pageNumber=${pageNumber} | |
&sortBy=${sortByField}&sortDirection=${sortDirection}}`, | |
{ | |
method: 'GET', | |
headers: { | |
'Content-Type': 'application/json', | |
Authorisation: `bearer ${token}`, | |
}, | |
} | |
) | |
.then((response) => response.json()) | |
.then((data) => data.comments) | |
.catch((error) => console.log(error)); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type BearerToken = string; | |
const getPosts = ( | |
token: BearerToken, | |
pageSize: number, | |
pageNumber: number, | |
sortByField: string, | |
sortDirection: SortDirection | |
) => { | |
return fetch( | |
`https://myblog.com/posts?pageSize=${pageSize}&pageNumber=${pageNumber} | |
&sortBy=${sortByField}&sortDirection=${sortDirection}}`, | |
{ | |
method: 'GET', | |
headers: { | |
'Content-Type': 'application/json', | |
Authorisation: `bearer ${token}`, | |
}, | |
} | |
) | |
.then((response) => response.json()) | |
.then((data) => data.posts) | |
.catch((error) => console.log(error)); | |
}; | |
const getComments = ( | |
token: BearerToken, | |
postId: string, | |
pageSize: number, | |
pageNumber: number, | |
sortByField: string, | |
sortDirection: SortDirection | |
) => { | |
return fetch( | |
`https://myblog.com/posts/${postId}/comments?pageSize=${pageSize}&pageNumber=${pageNumber} | |
&sortBy=${sortByField}&sortDirection=${sortDirection}}`, | |
{ | |
method: 'GET', | |
headers: { | |
'Content-Type': 'application/json', | |
Authorisation: `bearer ${token}`, | |
}, | |
} | |
) | |
.then((response) => response.json()) | |
.then((data) => data.comments) | |
.catch((error) => console.log(error)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment