HamzaMasood7 / Space-Chronicles

A journey through space visualizing mesmerizing images from NASA API
1 stars 3 forks source link

integrating React-query for api calls #13

Closed rahulpeacock closed 11 months ago

rahulpeacock commented 11 months ago

want to add react-query integration to the api calls 🚀

HamzaMasood7 commented 11 months ago

yes, you can add. can you brief on which API you will be adding?

rahulpeacock commented 11 months ago
  const [data, setData] = useState<PicDay | null>(null); 
   useEffect(() => { 
     const apiUrl = 'http://localhost:5000/earth/today'; 

     axios 
       .get(apiUrl) 
       .then((response) => { 
         const responseData: PicDay = response.data; 
         setData(responseData); 
       }) 
       .catch((error) => { 
         console.error('Error fetching data:', error); 
         setData(null); 
       }); 
   }, []);

I would like to use react-query for this fetch call

HamzaMasood7 commented 11 months ago

ok. you can create it.

rahulpeacock commented 11 months ago

yes 🍁

rahulpeacock commented 11 months ago

I am new to nest.js and prisma but I am getting this error, can you tell me how to resolve I am getting the error when I start the server using the command

pnpm run start

image

HamzaMasood7 commented 11 months ago

install prisma, apply prisma migrations npx prisma migrate status check if prisma is working and migrations status. it will create the table in database.

rahulpeacock commented 11 months ago

@HamzaMasood7 I am getting this still getting the error image

HamzaMasood7 commented 11 months ago

prisma is not installed. its giving error prisma command not found.

see this link. https://www.prisma.io/docs/guides/migrate/developing-with-prisma-migrate

rahulpeacock commented 11 months ago

prisma is not installed. its giving error prisma command not found.

see this link. https://www.prisma.io/docs/guides/migrate/developing-with-prisma-migrate

thanks for the support, it worked image

rahulpeacock commented 11 months ago

@HamzaMasood7 I have completed the react-query integration and made a PR #17

here is the video after integrating react-query

https://github.com/HamzaMasood7/Space-Chronicles/assets/87606332/5d619010-2371-44c3-af11-a11df80faa2f