Answer the question
In order to leave comments, you need to log in
Need help with json and bootstrap?
There is a json file that needs to be read and pulled out the values. And put all this into a card from bootstrap. I found several videos where everyone does this through a button (they call values from json). But how to put them just in a card?
import React, { useState } from 'react'
import { Card, Button } from 'react-bootstrap'
const FetchAPI = () => {
const {data, setData} = useState([])
const apiGet = () => {
fetch('https://jsonplaceholder.typicode.com/albums')
.then((response) => response.json())
.then((json) => {
setData(json);
})
};
return (
<Card style={{ width: '18rem' }}>
<Card.Img variant="top" src="holder.js/100px180" />
<Card.Body>
<Card.Title>{data.map(item => {item.title})}</Card.Title>
<Button variant="primary">Go somewhere</Button>
</Card.Body>
</Card>
)
}
export default FetchAPI;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question