Updated poetry to use latest api

Added poem id, changed url, fixed formatting, enabled actual fetching
This commit is contained in:
2023-08-08 18:30:29 +03:00
parent ea18439140
commit 60779ea489
5 changed files with 31 additions and 124 deletions

View File

@ -5,10 +5,11 @@ const initialPoetry: Poetry = {
title: '',
text: '',
author: '',
id: 0,
}
const composePoetryURL = () => (
API_URL + '/poetry?'
API_URL + '/user/poem?'
)
const processPoetry = (data: PoetryResponse): Poetry => {

View File

@ -4,6 +4,7 @@ type PoetryResponse = {
title: string,
text: string,
author: string,
id: number,
}
const isPoetryResponse = (obj: unknown): obj is PoetryResponse => (
@ -11,6 +12,7 @@ const isPoetryResponse = (obj: unknown): obj is PoetryResponse => (
'title': 'string',
'text': 'string',
'author': 'string',
'id': 'number',
})
)