Commit b2f4dd3a authored by Wietse Kuipers's avatar Wietse Kuipers
Browse files

Merge branch 'url' into 'master'

Added url.js and refactored actions to use it

See merge request !14
parents 3975f50f a4793f5b
import * as types from './actionTypes';
import { url } from '../url';
export function calendarRetrieved(eventList) {
return {
......@@ -27,7 +28,7 @@ export function retrieveCalendar(token) {
Authorization: `Token ${token}`,
},
};
return fetch(`http://localhost:8000/api/events/eventlist/?start=${start}&end=${end}`, data)
return fetch(`${url}/api/events/eventlist/?start=${start}&end=${end}`, data)
.then(
response => response.json())
.then(
......
import * as types from './actionTypes';
import { navigate } from './navigation';
import { url } from '../url';
export function success(data) {
return {
......@@ -24,7 +25,7 @@ export function loadEvent(id, token) {
Authorization: `Token ${token}`,
},
};
return fetch(`http://localhost:8000/api/events/data/?event_id=${id}`, data)
return fetch(`${url}/api/events/data/?event_id=${id}`, data)
.then(
response => response.json(),
)
......
import { AsyncStorage } from 'react-native';
import * as types from './actionTypes';
import { url } from '../url';
const USERNAMEKEY = '@MyStore:username';
const TOKENKEY = '@MyStore:token';
const DISPLAYNAMEKEY = '@MyStore:displayName';
const PHOTOKEY = '@MyStore:photo';
const defaultAvatar = 'http://localhost:8000/static/members/images/default-avatar.jpg';
const defaultAvatar = `${url}/static/members/images/default-avatar.jpg`;
export function loginSuccess(username, token, displayName, photo) {
return {
......@@ -43,7 +45,7 @@ function getUserInfo(token) {
},
};
return fetch('http://localhost:8000/api/members/info/', data)
return fetch(`${url}/api/members/info/`, data)
.then(
response => response.json())
.then(
......@@ -77,7 +79,7 @@ export function login(user, pass) {
password: pass,
}),
};
return fetch('http://localhost:8000/api/token-auth/', data)
return fetch(`${url}/api/token-auth/`, data)
.then(
response => response.json())
.then(
......
let server = 'https://thalia.nu';
if (__DEV__) { // eslint-disable-line no-undef
server = 'http://localhost:8000';
}
export const url = server;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment