source: my-react-app/src/components/AuthContent.js@ db39d9e

main
Last change on this file since db39d9e was db39d9e, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Authorization layer

  • Property mode set to 100644
File size: 907 bytes
Line 
1import * as React from 'react';
2import { request } from "../axios_helper";
3
4export default class AuthContent extends React.Component {
5 constructor(props) {
6 super(props);
7 this.state = {
8 data: []
9 };
10 }
11
12 componentDidMount() {
13 request(
14 "GET",
15 "/api/restaurants",
16 []
17 ).then((response) => {
18 this.setState({ data: response.data });
19 });
20 }
21
22 render() {
23 return (
24 <div>
25 {this.state.data && this.state.data.map((restaurant) => (
26 <div key={restaurant.restaurantId}>
27 <p>Name: {restaurant.name}</p>
28 <p>Cuisine Type: {restaurant.cuisineType}</p>
29 <p>Address: {restaurant.address}</p>
30
31 </div>
32 ))}
33 </div>
34 );
35 }
36}
Note: See TracBrowser for help on using the repository browser.