L
L
lum1ere2021-07-07 17:01:19
Bootstrap
lum1ere, 2021-07-07 17:01:19

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;

Error:
Failed to compile.

src\Components\card.js
Line 20:48: Expected an assignment or function call and instead saw an expression no-unused-expressionss

Search for the keywords to learn more about each error.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question