Skip to content

Instantly share code, notes, and snippets.

@imparvez
Created May 14, 2018 07:20
Show Gist options
  • Save imparvez/46d80675184aaae54c3bd1acb0ab8a65 to your computer and use it in GitHub Desktop.
Save imparvez/46d80675184aaae54c3bd1acb0ab8a65 to your computer and use it in GitHub Desktop.
Food List React App
import React, { Component } from 'react';
import axios from 'axios';
import './App.css';
class App extends Component {
constructor(props) {
super(props);
this.state = {
meal: ""
}
}
componentDidMount(){
const URL = 'https://www.themealdb.com/api/json/v1/1/latest.php';
axios.get(URL)
.then(res => {
const meal = res.data.meals; //Taking just the required data
if(typeof meal === 'object'){
this.setState({ meal });// setting it to state of our app
}
})
.catch(error => {
console.log(error);
});
}
render() {
return (
<div className="App">
</div>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment