added new login code and testing components

This commit is contained in:
2019-03-21 16:13:57 +01:00
parent 18f22fdffa
commit e04da5b273
11 changed files with 587 additions and 9 deletions

31
src/api/index.ts Normal file
View 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)
}