Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react axios project importing online same products with table from fake API

import React from 'react';
import './App.css';
import axios from 'axios';


 class App extends React.Component {
  state = {
      items: [ 
          

  ]
      
  }
  componentDidMount() {
          axios.get('https://fakestoreapi.com/products')
          .then( res => {
              const items= res.data;
              this.setState({ items});
          })

  }
  render(){
      return(
          <table>
          <thead>
              <tr>
                  <th>ID</th>
                  <th>Title</th>
                  <th>Price</th>
                  <th>Description</th>
                  <th>Image</th> 
                  <th>Rating</th>
              </tr>
          </thead>
          <tbody>
              {this.state.items.map((item)  =>
                  <tr>
                      <td>{item.id}</td>
                      <td>{item.title}</td>
                      <td>{item.price}</td>
                      <td>{item.description}</td>
                   <img src={item.image}/>
                      <td>{item.rating.rate}</td>
                  </tr>)}
          </tbody>
      </table>

      )
  }
}   
export default App;
Comment

PREVIOUS NEXT
Code Example
Javascript :: codigo para salvar javascript 
Javascript :: react email validation 
Javascript :: select 2 is not working in nodejs 
Javascript :: netsuite get search column value suitescript 
Javascript :: 404 error firebase react js 
Javascript :: hsv to rgb js 
Javascript :: Get Error 
Javascript :: reverse 
Javascript :: save input local storage react 
Javascript :: LeagueFlysystemAwsS3v3AwsS3Adapter 
Javascript :: nextjs youtube embed 
Javascript :: auto refresh vue pwa 
Javascript :: mobile version 
Javascript :: react-inline-script 
Javascript :: ajax fail function parameters 
Javascript :: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:compile 
Javascript :: deep copy array of objects javascript 
Javascript :: symfony iterate over entity 
Javascript :: javascript split string into groups of n 
Javascript :: react Examples of correct cod 
Javascript :: angular date passed to donet care is a day less 
Javascript :: node js orderby method 
Javascript :: command for importing fetchgraphqlquery in nextjs 
Javascript :: for (i = 0; i < N; i++) for (j = 0; j < N; j++) { .... some O(1) code ... } 
Javascript :: infinite typing effect react 
Javascript :: count object based on status and shop using javascript 
Javascript :: Angularjs $on called twice 
Javascript :: List of data with buttons that should display the rest of the data below 
Javascript :: how to send more than one array using response() json() in laravel 
Javascript :: setup app files in node js 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =