useResource "submit" method is mis-typed
pschwyter opened this issue · 1 comments
pschwyter commented
The submit
method seems to be mis-typed as being synchronous. However, it's an async function!
Code:
https://github.com/badgateway/react-ketting/blob/main/src/hooks/use-resource.ts#L86
const submit = async () => {
if (!resourceState || !resource) {
throw new Error('Too early to call submit()');
}
await resource.put(resourceState);
};
Type:
https://github.com/badgateway/react-ketting/blob/main/src/hooks/use-resource.ts#L21
// Send the state to the server via a PUT or POST request.
submit: (state?: ResourceState<T>) => void;
evert commented
Originally by design because I wasn't sure what we were going to do with this method, but at this point I think it's fine to change to Promise<void>