import React, { Component } from "react" import logo from "./logo.svg" import "./App.css" class LambdaDemo extends Component { constructor(props) { super(props) this.state = { loading: false, msg: null } } handleClick = api => e => { e.preventDefault() this.setState({ loading: true }) fetch("/.netlify/functions/" + api) .then(response => response.json()) .then(json => this.setState({ loading: false, msg: json.msg })) } render() { const { loading, msg } = this.state return (
{msg}
Edit src/App.js and save to reload.