React : How to Show Message if there is no records

前端 未结 5 1076
耶瑟儿~
耶瑟儿~ 2021-01-16 18:35

I am working on project in ReactJS, I am fetching data from server through API. I did some search filtration, I want to display message if there is no records available? I a

5条回答
  •  悲哀的现实
    2021-01-16 19:13

    I think a nice way would be to make your back end return a error message when there are no records to display. You could use .catch after your axios.get().then() function to see if there are any errors returned by back end and then display it to the user.

    Look: What is the proper REST response code for a valid request but an empty data?

提交回复
热议问题