所以这就是事情。我有端点,但不知道如何过滤响应并为每个对象以相同的方式列出结果。
我知道这是一个非常新手的介绍性问题,我感谢你们认为可以提供帮助的任何文章。
import React, { useEffect, useState } from 'react';
import ReactDOM from 'react-dom';
import '../assets/styles/Shared.css';
import { MDBBtn } from 'mdbreact';
/////
import axios from 'axios';
import api from '../services/api';
class Home extends React.Component {
render() {
return (
<>
<div className="CallApi">
<div className="container">
<h1 className="logo"></h1>
<h1 className="search">
<input className="form-control mr-sm-2" type="text" placeholder="Search for vehicle" onClick={null} />
<MDBBtn color="unique" rounded size="sm" type="submit" className="mr-auto">
Pesquisar
</MDBBtn>
<h1 className="hometext">THE SEARCH FOR THE VEHICLES</h1>
</h1>
</div>
</div>
</>
);
}
}
export default Home;
数据格式为:
{
"id": "1",
"title": "title 1",
"model": "model 1",
"brand": "brand 1",
"year": 69,
"color": 19,
"km": 79,
"price": 99
},