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

API request refactor #100

Merged
merged 8 commits into from
Sep 5, 2023
Merged

API request refactor #100

merged 8 commits into from
Sep 5, 2023

Conversation

jamiefeiss
Copy link
Collaborator

This PR refactors the fetch request composables to use async/await instead of callback functions. Error handling has also been improved, and api.ts now contains four composables to use:

  • useGetRequest(): Does a generic GET request using the fetch API. This is designed to be used for any non-Prez API & non-SPARQL GET requests if needed.
  • useApiRequest(): Does a GET request to the Prez API. Profiles are automatically parsed from the Link headers, and it expects a text/anot+turtle response. This is the composable pretty much every page uses to talk to the Prez API.
  • useConcurrentApiRequests(): Basically a parallel version of useApiRequest(), where you provide an array of URLs. In response you get an array of responses that contain the data and profiles for each individual request.
  • useSparqlRequest(): Does a SPARQL GET request (not specific to the Prez API). The composable will automatically determine if the response will be JSON or text/turtle based on the query.

The AltView.vue component has been removed as it's not being used as it has been replaced with ProfilesTable.vue.

edmondchuc
edmondchuc previously approved these changes Aug 30, 2023
@jamiefeiss jamiefeiss merged commit 6b8e4a1 into main Sep 5, 2023
@jamiefeiss jamiefeiss deleted the feature/api-requests-refactor branch September 5, 2023 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants