Skip to content

Commit 2fcb68d

Browse files
thzincbrettstack
andauthored
docs: fix stage variable in example app during local run (#627)
Co-authored-by: Brett Andrews <[email protected]>
1 parent fd705af commit 2fcb68d

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
const app = require('./src/app')
2-
const port = 3000
1+
const express = require("express");
2+
const app = require("./src/app");
3+
const port = 3000;
34

4-
app.listen(port)
5-
console.info(`listening on http://localhost:${port}`)
5+
express()
6+
.use("/Stage", app)
7+
.use("/", (req, res) => {
8+
res.redirect("/Stage");
9+
})
10+
.listen(port);
11+
console.info(`listening on http://localhost:${port}`);

examples/basic-starter-api-gateway-v1/src/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ router.get('/', (req, res) => {
2727
requestContext = {},
2828
multiValueHeaders = {}
2929
} = event
30-
const { stage = '' } = requestContext
30+
const { stage = 'Stage' } = requestContext
3131
const {
3232
Host = ['localhost:3000']
3333
} = multiValueHeaders

examples/basic-starter-api-gateway-v1/src/views/index.ejs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@
137137
</form>
138138
</section>
139139
<script>
140-
var form = document.querySelector('form')
141-
form.addEventListener('submit', function (event) {
140+
var form = document.querySelector('form')
141+
form.addEventListener('submit', function (event) {
142142
event.preventDefault()
143143
var id = document.getElementById('idField').value
144144
var name = document.getElementById('nameField').value
145-
var endpoint = id ? 'users/' + id : 'users'
146-
145+
var endpoint = "/<%= stage %>/" + (id ? "users/" + id : "users");
146+
147147
if (!window.fetch) {
148148
alert(
149149
'Your browser does not have fetch support, which this demo uses. Try again in a modern browser (https://caniuse.com/fetch) or modify the example to use an alternate approach (e.g. XMLHttpRequest or your library of choice.)'

0 commit comments

Comments
 (0)