Export request methods in api.js and include the api url in them
This commit is contained in:
parent
fdfcd5087d
commit
9dd2466e10
16
js/api.js
16
js/api.js
|
|
@ -34,20 +34,20 @@ const defaultstate_userinfo = {
|
||||||
uid : null
|
uid : null
|
||||||
}
|
}
|
||||||
|
|
||||||
function postRequest(url, data) {
|
export function postRequest(url, data) {
|
||||||
return axios.post(url, data, {
|
return axios.post(api_url + url, data, {
|
||||||
headers : generateHeaders()
|
headers : generateHeaders()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRequest(url, data) {
|
export function getRequest(url, data) {
|
||||||
return axios.get(url, data, {
|
return axios.get(api_url + url, data, {
|
||||||
headers : generateHeaders()
|
headers : generateHeaders()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteRequest(url, data) {
|
export function deleteRequest(url, data) {
|
||||||
return axios.delete(url, data, {
|
return axios.delete(api_url + url, data, {
|
||||||
headers : generateHeaders()
|
headers : generateHeaders()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -97,7 +97,7 @@ function checkForAuthenticationHeaders(response) {
|
||||||
const reducer_userinfo = (state = defaultstate_userinfo, action) => {
|
const reducer_userinfo = (state = defaultstate_userinfo, action) => {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case actiontypes_userinfo.REGISTER:
|
case actiontypes_userinfo.REGISTER:
|
||||||
postRequest(api_url + '/users', {
|
postRequest('/users', {
|
||||||
'username' : action.parameters.username,
|
'username' : action.parameters.username,
|
||||||
'email' : action.parameters.email,
|
'email' : action.parameters.email,
|
||||||
'password' : action.parameters.password
|
'password' : action.parameters.password
|
||||||
|
|
@ -138,7 +138,7 @@ const reducer_userinfo = (state = defaultstate_userinfo, action) => {
|
||||||
errorMessages : action.parameters.errorMessages
|
errorMessages : action.parameters.errorMessages
|
||||||
});
|
});
|
||||||
case actiontypes_userinfo.LOGIN:
|
case actiontypes_userinfo.LOGIN:
|
||||||
postRequest(api_url + '/users/sign_in', {
|
postRequest('/users/sign_in', {
|
||||||
email : action.parameters.email,
|
email : action.parameters.email,
|
||||||
password : action.parameters.password
|
password : action.parameters.password
|
||||||
}).then((resp) => {
|
}).then((resp) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue