Fix API calls.
This commit is contained in:
parent
55925383b7
commit
caf4c7fddf
2 changed files with 43 additions and 17 deletions
|
@ -367,19 +367,27 @@ const fetchMutes = ({credentials}) => {
|
|||
}).then((data) => data.json())
|
||||
}
|
||||
|
||||
const joinGroup = ({id, credentials}) => {
|
||||
const url = `${GROUP_JOINING_URL}/id.json`
|
||||
const fetchGroup = ({ groupName }) => {
|
||||
const url = `${GROUP_URL}/${groupName}.json`
|
||||
|
||||
return fetch(url).then((data) => data.json())
|
||||
}
|
||||
|
||||
const joinGroup = ({groupName, credentials}) => {
|
||||
const url = `${GROUP_JOINING_URL}/${groupName}.json`
|
||||
|
||||
return fetch(url, {
|
||||
headers: authHeaders(credentials)
|
||||
headers: authHeaders(credentials),
|
||||
method: 'POST'
|
||||
}).then((data) => data.json())
|
||||
}
|
||||
|
||||
const leaveGroup = ({id, credentials}) => {
|
||||
const url = `${GROUP_LEAVING_URL}/id.json`
|
||||
const leaveGroup = ({groupName, credentials}) => {
|
||||
const url = `${GROUP_LEAVING_URL}/${groupName}.json`
|
||||
|
||||
return fetch(url, {
|
||||
headers: authHeaders(credentials)
|
||||
headers: authHeaders(credentials),
|
||||
method: 'POST'
|
||||
}).then((data) => data.json())
|
||||
}
|
||||
|
||||
|
@ -406,8 +414,14 @@ const fetchMemberships = ({id, credentials}) => {
|
|||
}).then((data) => data.json())
|
||||
}
|
||||
|
||||
const fetchMembers = (id) => {
|
||||
const url = `${GROUP_MEMBERS_URL}/${id}.json`
|
||||
const fetchMembers = ({ groupName }) => {
|
||||
const url = `${GROUP_MEMBERS_URL}/${groupName}.json`
|
||||
|
||||
return fetch(url).then((data) => data.json())
|
||||
}
|
||||
|
||||
const fetchIsMember = ({id, groupName}) => {
|
||||
const url = `${GROUP_IS_MEMBER_URL}?user_id=${id}&group_name=${groupName}`
|
||||
|
||||
return fetch(url).then((data) => data.json())
|
||||
}
|
||||
|
@ -439,11 +453,13 @@ const apiService = {
|
|||
updateProfile,
|
||||
updateBanner,
|
||||
externalProfile,
|
||||
fetchGroup,
|
||||
joinGroup,
|
||||
leaveGroup,
|
||||
createGroup,
|
||||
fetchMemberships,
|
||||
fetchMembers
|
||||
fetchMembers,
|
||||
fetchIsMember
|
||||
}
|
||||
|
||||
export default apiService
|
||||
|
|
|
@ -50,20 +50,28 @@ const backendInteractorService = (credentials) => {
|
|||
return apiService.setUserMute({id, muted, credentials})
|
||||
}
|
||||
|
||||
const joinGroup = (id) => {
|
||||
return apiService.joinGroup({id, credentials})
|
||||
const fetchGroup = ({ groupName }) => {
|
||||
return apiService.fetchGroup({ groupName })
|
||||
}
|
||||
|
||||
const leaveGroup = (id) => {
|
||||
return apiService.leaveGroup({id, credentials})
|
||||
const joinGroup = ({ groupName }) => {
|
||||
return apiService.joinGroup({groupName, credentials})
|
||||
}
|
||||
|
||||
const fetchMemberships = (id) => {
|
||||
const leaveGroup = ({ groupName }) => {
|
||||
return apiService.leaveGroup({groupName, credentials})
|
||||
}
|
||||
|
||||
const fetchMemberships = ({ id }) => {
|
||||
return apiService.fetchMemberships({id, credentials})
|
||||
}
|
||||
|
||||
const fetchMembers = (id) => {
|
||||
return apiService.fetchMemberships({id, credentials})
|
||||
const fetchMembers = ({ groupName }) => {
|
||||
return apiService.fetchMembers({ groupName })
|
||||
}
|
||||
|
||||
const fetchIsMember = ({id, groupName}) => {
|
||||
return apiService.fetchIsMember({id, groupName})
|
||||
}
|
||||
|
||||
const createGroup = (params) => apiService.createGroup({params, credentials})
|
||||
|
@ -99,11 +107,13 @@ const backendInteractorService = (credentials) => {
|
|||
updateBanner,
|
||||
updateProfile,
|
||||
externalProfile,
|
||||
fetchGroup,
|
||||
joinGroup,
|
||||
leaveGroup,
|
||||
createGroup,
|
||||
fetchMemberships,
|
||||
fetchMembers
|
||||
fetchMembers,
|
||||
fetchIsMember
|
||||
}
|
||||
|
||||
return backendInteractorServiceInstance
|
||||
|
|
Loading…
Reference in a new issue