31 lines
891 B
TypeScript
31 lines
891 B
TypeScript
import axios from 'axios';
|
|
|
|
const API_URL = 'http://localhost:5443/api';
|
|
|
|
export function fetchSurveys () {
|
|
return axios.get(`${API_URL}/surveys/`)
|
|
}
|
|
|
|
export function fetchSurvey (surveyId: string) {
|
|
return axios.get(`${API_URL}/surveys/${surveyId}/`)
|
|
}
|
|
|
|
export function saveSurveyResponse (surveyResponse: any) {
|
|
return axios.put(`${API_URL}/surveys/${surveyResponse.id}/`, surveyResponse)
|
|
}
|
|
|
|
export function postNewSurvey (survey: any, jwt: any) {
|
|
return axios.post(`${API_URL}/surveys/`, survey, { headers: { Authorization: `Bearer: ${jwt}` } })
|
|
}
|
|
|
|
export function authenticate (userData: any) {
|
|
return axios.post(`${API_URL}/auth/login`, userData)
|
|
}
|
|
|
|
export function register (userData: any) {
|
|
return axios.post(`${API_URL}/auth/register`, userData)
|
|
}
|
|
|
|
export function getProviders (providers: any) {
|
|
return axios.get(`${API_URL}/auth/providers`, providers)
|
|
} |