fix: Move to the new API scheme

This commit is contained in:
Alexander Polynomdivision 2018-09-23 22:22:22 +02:00
parent 2c4011f631
commit 11bbdc627f
2 changed files with 6 additions and 5 deletions

View File

@ -17,7 +17,7 @@ watch: node_modules
.PHONY: build
build: node_modules dist/minified
@echo Building with parcel
./node_modules/.bin/parcel build
./node_modules/.bin/parcel build src/index.html
@echo Minifying
$(foreach file, $(wildcard dist/*.js), $(call minify, $(file)))

View File

@ -40,6 +40,7 @@ export default class Application extends React.Component<IProps> {
// TODO: When asking the server if our session is still valid, a spinner
// should be shown
if (getSessionToken(window) !== null) {
// TODO: We still need to fetch the user data
this.props.setAuthenticated(true);
}
}
@ -143,7 +144,7 @@ export default class Application extends React.Component<IProps> {
getTopTenLearners = (): Promise<TopTen[]> => {
const id = this.props.user.classId;
return new Promise((res, rej) => {
fetch(`${BACKEND_URL}/auth/class/${id}/topTen`, {
fetch(`${BACKEND_URL}/api/class/${id}/topTen`, {
headers: new Headers({
"Content-Type": "application/json",
"Token": this.props.user.sessionToken,
@ -162,7 +163,7 @@ export default class Application extends React.Component<IProps> {
getNextLevel = (): Promise<ILevel> => {
return new Promise((res, rej) => {
fetch(`${BACKEND_URL}/auth/user/nextLevel`, {
fetch(`${BACKEND_URL}/api/user/nextLevel`, {
headers: new Headers({
"Content-Type": "application/json",
"Token": this.props.user.sessionToken,
@ -181,7 +182,7 @@ export default class Application extends React.Component<IProps> {
getLevelVocab = (id: number): Promise<IVocab[]> => {
return new Promise((res, rej) => {
fetch(`${BACKEND_URL}/auth/level/${id}/vocab`, {
fetch(`${BACKEND_URL}/api/level/${id}/vocab`, {
method: "GET",
headers: new Headers({
"Content-Type": "application/json",
@ -201,7 +202,7 @@ export default class Application extends React.Component<IProps> {
login = (username: string, password: string): Promise<IUser | IResponse> => {
return new Promise((res, rej) => {
fetch(`${BACKEND_URL}/login`, {
fetch(`${BACKEND_URL}/api/login`, {
method: "POST",
headers: new Headers({
"Content-Type": "application/json",