File tree Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change 3
3
"version" : " 0.1.0" ,
4
4
"private" : true ,
5
5
"dependencies" : {
6
- "netlify-lambda" : " ^0.0.1 " ,
6
+ "netlify-lambda" : " ^0.1.0 " ,
7
7
"react" : " ^16.1.0" ,
8
8
"react-dom" : " ^16.1.0" ,
9
9
"react-scripts" : " 1.0.17"
Original file line number Diff line number Diff line change @@ -2,6 +2,31 @@ import React, { Component } from 'react';
2
2
import logo from './logo.svg' ;
3
3
import './App.css' ;
4
4
5
+ class LambdaDemo extends Component {
6
+ constructor ( props ) {
7
+ super ( props ) ;
8
+ this . state = { loading : false , msg : null } ;
9
+ }
10
+
11
+ handleClick = ( e ) => {
12
+ e . preventDefault ( ) ;
13
+
14
+ this . setState ( { loading : true } ) ;
15
+ fetch ( '/.netlify/functions/hello' )
16
+ . then ( response => response . json ( ) )
17
+ . then ( json => this . setState ( { loading : false , msg : json . msg } ) ) ;
18
+ }
19
+
20
+ render ( ) {
21
+ const { loading, msg} = this . state ;
22
+
23
+ return < p >
24
+ < button onClick = { this . handleClick } > { loading ? 'Loading...' : 'Call Lambda' } </ button > < br />
25
+ < span > { msg } </ span >
26
+ </ p >
27
+ }
28
+ }
29
+
5
30
class App extends Component {
6
31
render ( ) {
7
32
return (
@@ -13,6 +38,7 @@ class App extends Component {
13
38
< p className = "App-intro" >
14
39
To get started, edit < code > src/App.js</ code > and save to reload.
15
40
</ p >
41
+ < LambdaDemo />
16
42
</ div >
17
43
) ;
18
44
}
Original file line number Diff line number Diff line change @@ -4217,9 +4217,9 @@ negotiator@0.6.1:
4217
4217
version "0.6.1"
4218
4218
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9"
4219
4219
4220
- netlify-lambda@^0.0.1 :
4221
- version "0.0.1 "
4222
- resolved "https://registry.yarnpkg.com/netlify-lambda/-/netlify-lambda-0.0.1. tgz#3c4967afd0252ccb60041b8c9223f0f4faf2a731 "
4220
+ netlify-lambda@^0.1.0 :
4221
+ version "0.1.0 "
4222
+ resolved "https://registry.yarnpkg.com/netlify-lambda/-/netlify-lambda-0.1.0. tgz#7993b7dff0fa93b1b99576d453e7dd79e78790d5 "
4223
4223
dependencies :
4224
4224
babel-plugin-transform-class-properties "^6.24.1"
4225
4225
babel-plugin-transform-object-assign "^6.22.0"
You can’t perform that action at this time.
0 commit comments