Created On: May 09, 2024, Last Updated On: May 09, 2024

React API

Public

By Ozzie Ghani3 new




import {useState, useEffect} from 'react';
import { Channel } from './Components/Channel/Channel'

function App() {
    const [intialState, setState] = useState([])
    const url = '/api'

    useEffect(() => {
      fetch(url).then(response => {
        if (response.status == 200){
          return response.json()
        }

      }).then(data => setState(data))
}, [] )


  return (
    <div className="container">
    <Channel data={intialState}/>
    </div>
  );
}

export default App;



import React from 'react';


export const Channel = ({data}) => {
  return(
    <div>
      <h1>{data.channel}</h1>
      <h3>{data.tutorial}</h3>
      <h3>hhh</h3>
    </div>
  )
}