React — Fetch

Stela Capsa
Aug 3, 2021

We all know that React is a frontend JavaScript library. Fetching in react is a way of manipulating data API.

pictures table
users table

If we have this two tables builded in Rails as data base to be manipulated and the data JASON looks like:

Users table
Pictures table

Picture with id: 36 belongs_to user_id: 40 that has user_name: “Juan” and also it has a description and image_url.

fetching pictures URL

The state is an empty array, with fetch we bring the data from the Rails backend to the React frontend. With the key picture can display the data and style it.

Happy Coding!

--

--