added new login code and testing components
This commit is contained in:
31
src/api/index.ts
Normal file
31
src/api/index.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user