mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 07:04:45 -04:00
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:
parent
4a18e51c83
commit
9cf7980334
38 changed files with 268 additions and 164 deletions
|
@ -5,31 +5,17 @@
|
|||
*/
|
||||
|
||||
import { defaultFetchConfig, expectResponseCode, getApiUrl } from '../utils'
|
||||
import { NoteDto } from './types'
|
||||
import { isMockMode } from '../../utils/test-modes'
|
||||
|
||||
interface LastChange {
|
||||
userId: string
|
||||
timestamp: number
|
||||
}
|
||||
|
||||
export interface Note {
|
||||
id: string
|
||||
alias: string
|
||||
lastChange: LastChange
|
||||
viewCount: number
|
||||
createTime: number
|
||||
content: string
|
||||
authorship: number[]
|
||||
preVersionTwoNote: boolean
|
||||
}
|
||||
|
||||
export const getNote = async (noteId: string): Promise<Note> => {
|
||||
export const getNote = async (noteId: string): Promise<NoteDto> => {
|
||||
// The "-get" suffix is necessary, because in our mock api (filesystem) the note id might already be a folder.
|
||||
// TODO: [mrdrogdrog] replace -get with actual api route as soon as api backend is ready.
|
||||
const response = await fetch(getApiUrl() + `/notes/${ noteId }-get`, {
|
||||
const response = await fetch(getApiUrl() + `/notes/${ noteId }${ isMockMode() ? '-get' : '' }`, {
|
||||
...defaultFetchConfig
|
||||
})
|
||||
expectResponseCode(response)
|
||||
return await response.json() as Promise<Note>
|
||||
return await response.json() as Promise<NoteDto>
|
||||
}
|
||||
|
||||
export const deleteNote = async (noteId: string): Promise<void> => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue