jam-cloud/jam-ui/src/helpers/rest.js

53 lines
1.3 KiB
JavaScript
Raw Normal View History

import { reject } from "lodash";
import apiFetch from "./apiFetch";
export const getPeople = () => {
return new Promise((resolve, reject) => {
apiFetch("/search/musicians?results=true")
.then(response => resolve(response))
.catch(error => reject(error))
})
}
export const getUserProfile = (id) => {
return new Promise((resolve, reject) => (
apiFetch(`/users/${id}/profile?show_teacher=true`)
.then(response => resolve(response))
.catch(error => reject(error))
))
}
export const postPeopleSearch = (data) => {
return new Promise((resolve, reject) => {
apiFetch("/filter", {
method: 'POST',
body: JSON.stringify(data)
})
.then(response => resolve(response))
.catch(error => reject(error))
})
}
export const getGenres = () => {
return new Promise((resolve, reject) => {
apiFetch('/genres')
.then(response => resolve(response))
.catch(error => reject(error))
})
}
export const getInstruments = () => {
return new Promise((resolve, reject) => {
apiFetch('/instruments')
.then(response => resolve(response))
.catch(error => reject(error))
})
}
export const getCurrentUser = () => {
return new Promise((resolve, reject) => {
apiFetch('/me')
.then(response => resolve(response))
.catch(error => reject(error))
})
}