Skip to content

Commit 06d4d73

Browse files
author
sw-yx
committed
update deps and dadjoke
1 parent 459b202 commit 06d4d73

File tree

4 files changed

+43
-47
lines changed

4 files changed

+43
-47
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"@babel/plugin-transform-object-assign": "^7.0.0",
3232
"babel-loader": "8.0.4",
3333
"http-proxy-middleware": "^0.19.0",
34-
"netlify-lambda": "^1.4.2",
34+
"netlify-lambda": "^1.4.4",
3535
"npm-run-all": "^4.1.5"
3636
}
3737
}

src/App.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,33 @@
1-
import React, { Component } from 'react';
2-
import logo from './logo.svg';
3-
import './App.css';
1+
import React, { Component } from "react"
2+
import logo from "./logo.svg"
3+
import "./App.css"
44

55
class LambdaDemo extends Component {
66
constructor(props) {
7-
super(props);
8-
this.state = { loading: false, msg: null };
7+
super(props)
8+
this.state = { loading: false, msg: null }
99
}
1010

1111
handleClick = api => e => {
12-
e.preventDefault();
12+
e.preventDefault()
1313

14-
this.setState({ loading: true });
15-
fetch('/.netlify/functions/' + api)
14+
this.setState({ loading: true })
15+
fetch("/.netlify/functions/" + api)
1616
.then(response => response.json())
17-
.then(json => this.setState({ loading: false, msg: json.msg }));
18-
};
17+
.then(json => this.setState({ loading: false, msg: json.msg }))
18+
}
1919

2020
render() {
21-
const { loading, msg } = this.state;
21+
const { loading, msg } = this.state
2222

2323
return (
2424
<p>
25-
<button onClick={this.handleClick('hello')}>
26-
{loading ? 'Loading...' : 'Call Lambda'}
27-
</button>
28-
<button onClick={this.handleClick('async-chuck-norris')}>
29-
{loading ? 'Loading...' : 'Call Async Lambda'}
30-
</button>
25+
<button onClick={this.handleClick("hello")}>{loading ? "Loading..." : "Call Lambda"}</button>
26+
<button onClick={this.handleClick("async-dadjoke")}>{loading ? "Loading..." : "Call Async Lambda"}</button>
3127
<br />
3228
<span>{msg}</span>
3329
</p>
34-
);
30+
)
3531
}
3632
}
3733

@@ -47,8 +43,8 @@ class App extends Component {
4743
<LambdaDemo />
4844
</header>
4945
</div>
50-
);
46+
)
5147
}
5248
}
5349

54-
export default App;
50+
export default App
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
// example of async handler using async-await
22
// https://github.com/netlify/netlify-lambda/issues/43#issuecomment-444618311
33

4-
import fetch from 'node-fetch';
4+
import fetch from "node-fetch"
55
export async function handler(event, context) {
66
try {
7-
const response = await fetch('https://api.chucknorris.io/jokes/random');
7+
const response = await fetch("https://icanhazdadjoke.com", { headers: { Accept: "application/json" } })
88
if (!response.ok) {
99
// NOT res.status >= 200 && res.status < 300
10-
return { statusCode: response.status, body: response.statusText };
10+
return { statusCode: response.status, body: response.statusText }
1111
}
12-
const data = await response.json();
12+
const data = await response.json()
1313

1414
return {
1515
statusCode: 200,
16-
body: JSON.stringify({ msg: data.value })
17-
};
16+
body: JSON.stringify({ msg: data.joke })
17+
}
1818
} catch (err) {
19-
console.log(err); // output to netlify function log
19+
console.log(err) // output to netlify function log
2020
return {
2121
statusCode: 500,
2222
body: JSON.stringify({ msg: err.message }) // Could be a custom message or object i.e. JSON.stringify(err)
23-
};
23+
}
2424
}
2525
}

yarn.lock

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6555,10 +6555,10 @@ neo-async@^2.5.0:
65556555
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.0.tgz#b9d15e4d71c6762908654b5183ed38b753340835"
65566556
integrity sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==
65576557

6558-
netlify-lambda@^1.4.2:
6559-
version "1.4.2"
6560-
resolved "https://registry.yarnpkg.com/netlify-lambda/-/netlify-lambda-1.4.2.tgz#cd4972c942e449c64b30d58ca7d7725a58547fb7"
6561-
integrity sha512-Iy9SoS0sAyAHP8Bg93kLO+/RJkSf8Q0NqzBchMNAa6xKbDmcTxqg6crMk3mRNkCewgWhvN5uGSWmaA7FZHN1sQ==
6558+
netlify-lambda@^1.4.4:
6559+
version "1.4.4"
6560+
resolved "https://registry.yarnpkg.com/netlify-lambda/-/netlify-lambda-1.4.4.tgz#aea020ae6704af99e9a19b2f0569738dc9c49505"
6561+
integrity sha512-2d2b5h+24rRloiGgIoOUY90EPjFCTxprm3XOl/6dHg+BIopBQShMUww9ixllXxZFy4SZurOFkE1LwFyk4RRbYQ==
65626562
dependencies:
65636563
"@babel/core" "^7.0.0"
65646564
"@babel/plugin-proposal-class-properties" "^7.0.0"
@@ -8175,15 +8175,15 @@ react-dev-utils@^7.0.1:
81758175
strip-ansi "4.0.0"
81768176
text-table "0.2.0"
81778177

8178-
react-dom@^16.8.0-alpha.0:
8179-
version "16.8.0-alpha.0"
8180-
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.8.0-alpha.0.tgz#47bbcf42593eab5468b577d3c3f3c27f251a65ef"
8181-
integrity sha512-OGfLUXGxtMgqLB1BqnB9flVCvc8VvAnhQYeFr+EUzwiODcD34dPrxtfa7ccK4dwzcPi8HRLSyBcaQi2OvVoUww==
8178+
react-dom@^16.8.6:
8179+
version "16.8.6"
8180+
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.8.6.tgz#71d6303f631e8b0097f56165ef608f051ff6e10f"
8181+
integrity sha512-1nL7PIq9LTL3fthPqwkvr2zY7phIPjYrT0jp4HjyEQrEROnw4dG41VVwi/wfoCneoleqrNX7iAD+pXebJZwrwA==
81828182
dependencies:
81838183
loose-envify "^1.1.0"
81848184
object-assign "^4.1.1"
81858185
prop-types "^15.6.2"
8186-
scheduler "^0.13.0-alpha.0"
8186+
scheduler "^0.13.6"
81878187

81888188
react-error-overlay@^5.1.2:
81898189
version "5.1.2"
@@ -8245,15 +8245,15 @@ react-scripts@^2.1.3:
82458245
optionalDependencies:
82468246
fsevents "1.2.4"
82478247

8248-
react@^16.8.0-alpha.0:
8249-
version "16.8.0-alpha.0"
8250-
resolved "https://registry.yarnpkg.com/react/-/react-16.8.0-alpha.0.tgz#8545eb79534cce5ba99ed40085f7f955e8857a19"
8251-
integrity sha512-B/nJJkNqV4JAJQ1M0Q38ZvhZ6BoYsjyZq29hbsIIPYayn/0DcYhu7tExpfzdtTC0SnUcA+RnDBTlXTEJ5b9PEg==
8248+
react@^16.8.6:
8249+
version "16.8.6"
8250+
resolved "https://registry.yarnpkg.com/react/-/react-16.8.6.tgz#ad6c3a9614fd3a4e9ef51117f54d888da01f2bbe"
8251+
integrity sha512-pC0uMkhLaHm11ZSJULfOBqV4tIZkx87ZLvbbQYunNixAAvjnC+snJCg0XQXn9VIsttVsbZP/H/ewzgsd5fxKXw==
82528252
dependencies:
82538253
loose-envify "^1.1.0"
82548254
object-assign "^4.1.1"
82558255
prop-types "^15.6.2"
8256-
scheduler "^0.13.0-alpha.0"
8256+
scheduler "^0.13.6"
82578257

82588258
read-pkg-up@^1.0.1:
82598259
version "1.0.1"
@@ -8725,10 +8725,10 @@ saxes@^3.1.4:
87258725
dependencies:
87268726
xmlchars "^1.3.1"
87278727

8728-
scheduler@^0.13.0-alpha.0:
8729-
version "0.13.0-alpha.0"
8730-
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.0-alpha.0.tgz#8fc1f01617b59e4543376735b2f954867d49110c"
8731-
integrity sha512-+DbRwO53hlLso4gzrSIqcfNe8eRMMaV4gd4eySGisbyLBrp5unTpAMR0UAbrqlQLTGhnOFNoQAfaZTz4iPj1RQ==
8728+
scheduler@^0.13.6:
8729+
version "0.13.6"
8730+
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.6.tgz#466a4ec332467b31a91b9bf74e5347072e4cd889"
8731+
integrity sha512-IWnObHt413ucAYKsD9J1QShUKkbKLQQHdxRyw73sw4FN26iWr3DY/H34xGPe4nmL1DwXyWmSWmMrA9TfQbE/XQ==
87328732
dependencies:
87338733
loose-envify "^1.1.0"
87348734
object-assign "^4.1.1"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy