Closed sysmat closed 1 year ago
import * as r from 'radash'; ... // radash way not working as expected const [err, god] = await r.try(updateHuman)(prop.index, human); console.error('error=', err); // err is undefined console.log('god=', god); // god={ "detail": "Method 'POST' not allowed."} // old way works fine updateHuman(prop.index, human).then(ok => { prop.setHuman(human); prop.edit(false); }).catch(err => { console.log('updateHuman=', err); setError('error when updating human') }); export const updateHuman = async (id: number, human: Human): Promise<Human> => ( await fetch(`https://swapi.dev/api/people/${id}/`, { method: 'POST', headers: jwt, body: JSON.stringify(human) })).json();
My mistake