Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- class Public extends React.Component {
- state = {
- message: ""
- }
- componentDidMount() {
- fetch('/public').then(response => {
- if (response.ok) return response.json();
- throw new Error("Network response was not OK.");
- })
- .then(response => this.setState({ message: response.message }))
- .catch(error => this.setState({ message: error.message }));
- }
- render() {
- return (
- <p>{this.state.message}</p>
- );
- }
- }
- export default Public;
Add Comment
Please, Sign In to add comment