Skip to content

Commit

Permalink
Populate all api calls
Browse files Browse the repository at this point in the history
  • Loading branch information
paularintaharri committed Nov 24, 2023
1 parent 809b120 commit ca5819f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,39 @@ export const fetchAgeGroups = async (language) => {
}

export const fetchSingleAgeGroup = async (id) => {
const res = await fetch(`${PARTIO_API_URL}/age-groups/${id}`)
const res = await fetch(`${PARTIO_API_URL}/age-groups/${id}?populate=*`)
const ageGroup = await res.json()
return ageGroup.data
}

export const fetchActivityGroups = async (language) => {
const locale = language === undefined ? 'fi' : language
const countRes = await fetch(
`${PARTIO_API_URL}/activity-groups?locale=${locale}`
`${PARTIO_API_URL}/activity-groups?populate=*&locale=${locale}`
)
const count = await countRes.json()
const res = await fetch(
`${PARTIO_API_URL}/activity-groups?pagination[start]=0&pagination[limit]=${count.meta.pagination.total}&locale=${locale}`
`${PARTIO_API_URL}/activity-groups?pagination[start]=0&pagination[limit]=${count.meta.pagination.total}&locale=${locale}&populate=*`
)
const activityGroups = await res.json()
return activityGroups.data
}

export const fetchSingleActivityGroup = async (id) => {
const res = await fetch(`${PARTIO_API_URL}/activity-groups/${id}`)
const res = await fetch(`${PARTIO_API_URL}/activity-groups/${id}?populate=*`)
const activityGroup = await res.json()
return activityGroup.data
}

export const fetchActivities = async () => {
const res = await fetch(`${PARTIO_API_URL}/activities`)
const res = await fetch(`${PARTIO_API_URL}/activities?populate=*`)
const activities = await res.json()
return activities.data
}

export const fetchActivity = async (wp_guid, language) => {
const res = await fetch(
`${PARTIO_API_URL}/activities?wp_guid=${wp_guid}&locale=${language}`
`${PARTIO_API_URL}/activities?populate=*&wp_guid=${wp_guid}&locale=${language}`
)
const activity = await res.json()
return activity.data
Expand All @@ -57,9 +57,12 @@ export const fetchTaskDetails = async (guid, lang) => {
}

export const fetchTranslations = async (lang) => {
const res = await await fetch(`${PARTIO_API_URL}/setting?locale=${lang}`)
const res = await await fetch(
`${PARTIO_API_URL}/setting?populate=*&locale=${lang}`
)
const translations = await res.json()
return translations.data
console.log(translations)
return translations.data.translations
}

// POS BACKEND
Expand Down

0 comments on commit ca5819f

Please sign in to comment.