Skip to content
Advertisement

Trying to fetch APi but it is not displaying the data

I have created Context API I am trying to fetch the data from my API so I can use the state globally, but is not doing it. I am not getting any errors in the console. But when I try to fetch from the Other Component, I am getting data in the console. Just in the Context, I am not getting it.

JavaScript

Advertisement

Answer

try setTrucks([...response.data])

Advertisement