-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5faceef
commit 00a7271
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const collectionsRoute = 'https://girlswritenow.org/wp-json/wp/v2/collection'; | ||
const storyRoute = 'https://girlswritenow.org/wp-json/wp/v2/story'; | ||
const topicRoute = 'https://girlswritenow.org/wp-json/wp/v2/topic'; | ||
|
||
export const getAllCollections = async (): Promise<JSON[]> => { | ||
// what is the tyoe that goes in this promise? | ||
try { | ||
const response = await fetch(collectionsRoute); | ||
const responseJson = await response.json(); | ||
console.log(responseJson); | ||
return responseJson; | ||
} catch (error) { | ||
console.log('Error'); | ||
throw error; | ||
} | ||
}; | ||
|
||
export const getCollectionById = async (id: string): Promise<JSON> => { | ||
try { | ||
const response = await fetch(collectionsRoute); | ||
const responseJson = await response.json(); | ||
const responseObj = responseJson.map( | ||
(obj: { id: string }) => obj.id === id, | ||
); | ||
console.log(response); | ||
return responseObj; | ||
} catch (error) { | ||
console.log('Error'); | ||
throw error; | ||
} | ||
}; | ||
|
||
// export const getCollection = async (id: string) => { | ||
// try { | ||
// const response = await fetch("https://girlswritenow.org/wp-json/wp/v2/collection") | ||
// } catch (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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// export default function QueriesTestScreen.tsx |