react-request-hook icon indicating copy to clipboard operation
react-request-hook copied to clipboard

Add response code?

Open speedbird25 opened this issue 5 years ago • 3 comments

Currently I use the useResource hook. I am trying to get the response code from this hook, however only the response.data and no response.code (coming from axios) is returned. In my case I have to deal with a no content 204 response, however in this case where response.data is undefined I did not find any way to find out if the request was successful or not.

Is there any way to find out the response code, e.g. using useRequest hook and ready()?

speedbird25 avatar Aug 20 '20 12:08 speedbird25

Currently I use the useResource hook. I am trying to get the response code from this hook, however only the response.data and no response.code (coming from axios) is returned. In my case I have to deal with a no content 204 response, however in this case where response.data is undefined I did not find any way to find out if the request was successful or not.

Is there any way to find out the response code, e.g. using useRequest hook and ready()?

I have the same request.

cmelion avatar Oct 27 '20 19:10 cmelion

Hi~ Maybe try this https://github.com/react-cmpt/react-request-hook/blob/main/CHANGELOG.md#300-2021-01-03

wangcch avatar Jan 03 '21 11:01 wangcch

Had to deal with 204 responses last week to close a modal and reload a datagrid. Just check if response.data === ''

PunkOnWheels avatar Feb 19 '21 19:02 PunkOnWheels