Can't get Data while fetching from React Error(304)

Viewed 869

While i'm using axios to fetch data it's return 304 on React . But it's work on Postman !

 const [mangas, setMangas] = useState([])
        
          useEffect(() => {
            const getMangas = async () => {
              const res = await axios.get('/mangas')
              setMangas(res.data)
            }
            getMangas()
          }, [])
          console.log(mangas)

::ffff:127.0.0.1 - - [16/Aug/2021:10:34:12 +0000] "GET /api/mangas HTTP/1.1" 304 -

Morgan return this message on React!

  router.get('/', async (req, res) => {
          try {
            const mangas = await Manga.find()
            res.status(200).json(mangas.reverse())
          } catch (err) {
            res.status(500).json(err)
          }
        })

::1 - - [16/Aug/2021:10:34:44 +0000] "GET /api/mangas HTTP/1.1" 200 5763

this is from Postman!

i tried to clear Browser'Cache but it doen't work

1 Answers

304 is not an error. it means the result of the request is the same as the last request the client did. react knows how to handle this. You should consider it as "all good. data fetched from cache client side".

what is your problem ?

Related