Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daan #23

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

Daan #23

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
7 changes: 7 additions & 0 deletions .idea/discord.xml

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

19 changes: 19 additions & 0 deletions .idea/php.xml

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

8 changes: 8 additions & 0 deletions .idea/pleasurable-ui-team-oba.iml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

90 changes: 90 additions & 0 deletions .idea/workspace.xml

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

20 changes: 20 additions & 0 deletions helpers/fetch-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* An asynchronous helper function that wraps the standard node.js fetch API.
* This function calls an API url passed as the first and mandatory parameter,
* there is an optional payload parameter to send a json object, eg. a filter.
* It then calls the API and returns the response body parsed as a json object.
* @example <caption>fetchJson as returning function using the await keyword</caption>
* const data = await fetchJson('https://api-url.com/endpoint/')
* @example <caption>fetchJson as oneliner using the then() structure.</caption>
* fetchJson('https://api-url.com/endpoint/').then((data)=>{
* // use data...
* })
* @param {string} url the api endpoint to address
* @param {object} [payload] the payload to send to the API
* @returns the response from the API endpoint parsed as a json object
*/
export default async function fetchJson(url, payload = {}) {
return await fetch(url, payload)
.then((response) => response.json())
.catch((error) => error)
}
Loading