Fix Communication between frontend and backend (#1201)

Co-authored-by: Tilman Vatteroth <git@tilmanvatteroth.de>
Signed-off-by: Philip Molares <philip.molares@udo.edu>
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Philip Molares 2021-05-01 23:01:42 +02:00 committed by GitHub
parent 4a18e51c83
commit 9cf7980334
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 268 additions and 164 deletions

View file

@ -8,13 +8,13 @@ import { defaultFetchConfig, expectResponseCode, getApiUrl } from '../utils'
import { HistoryEntryDto, HistoryEntryPutDto, HistoryEntryUpdateDto } from './types'
export const getHistory = async (): Promise<HistoryEntryDto[]> => {
const response = await fetch(getApiUrl() + '/history')
const response = await fetch(getApiUrl() + '/me/history')
expectResponseCode(response)
return await response.json() as Promise<HistoryEntryDto[]>
}
export const postHistory = async (entries: HistoryEntryPutDto[]): Promise<void> => {
const response = await fetch(getApiUrl() + '/history', {
const response = await fetch(getApiUrl() + '/me/history', {
...defaultFetchConfig,
method: 'POST',
body: JSON.stringify(entries)
@ -23,7 +23,7 @@ export const postHistory = async (entries: HistoryEntryPutDto[]): Promise<void>
}
export const updateHistoryEntryPinStatus = async (noteId: string, entry: HistoryEntryUpdateDto): Promise<void> => {
const response = await fetch(getApiUrl() + '/history/' + noteId, {
const response = await fetch(getApiUrl() + '/me/history/' + noteId, {
...defaultFetchConfig,
method: 'PUT',
body: JSON.stringify(entry)
@ -32,7 +32,7 @@ export const updateHistoryEntryPinStatus = async (noteId: string, entry: History
}
export const deleteHistoryEntry = async (noteId: string): Promise<void> => {
const response = await fetch(getApiUrl() + '/history/' + noteId, {
const response = await fetch(getApiUrl() + '/me/history/' + noteId, {
...defaultFetchConfig,
method: 'DELETE'
})
@ -40,7 +40,7 @@ export const deleteHistoryEntry = async (noteId: string): Promise<void> => {
}
export const deleteHistory = async (): Promise<void> => {
const response = await fetch(getApiUrl() + '/history', {
const response = await fetch(getApiUrl() + '/me/history', {
...defaultFetchConfig,
method: 'DELETE'
})