質問編集履歴

5

ソースにjavascript追加

2019/01/12 06:12

投稿

police
police

スコア14

test CHANGED
File without changes
test CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  colors.htmlのソースを見ると、
16
16
 
17
- ```
17
+ ```javascript
18
18
 
19
19
  // create an array with nodes
20
20
 
@@ -68,7 +68,7 @@
68
68
 
69
69
  以下、Expressの/routes/index.js
70
70
 
71
- ```
71
+ ```javascript
72
72
 
73
73
  const express = require('express');
74
74
 

4

若干修正

2019/01/12 06:12

投稿

police
police

スコア14

test CHANGED
File without changes
test CHANGED
@@ -136,7 +136,7 @@
136
136
 
137
137
  if (req.query.p) obj = await getFunc(req.query.p);
138
138
 
139
- res.render('index', { obj: obj??? }); // ここはわからないので間違ってます
139
+ res.render('index', { obj: obj });
140
140
 
141
141
  });
142
142
 

3

もろもろ修正

2019/01/12 06:11

投稿

police
police

スコア14

test CHANGED
File without changes
test CHANGED
@@ -132,11 +132,9 @@
132
132
 
133
133
  router.get('/', async (req, res, next) => {
134
134
 
135
- if (req.query.p) {
135
+ let obj;
136
136
 
137
- const obj = await getFunc(req.query.p);
137
+ if (req.query.p) obj = await getFunc(req.query.p);
138
-
139
- };
140
138
 
141
139
  res.render('index', { obj: obj??? }); // ここはわからないので間違ってます
142
140
 

2

変数一つ削除

2019/01/11 12:54

投稿

police
police

スコア14

test CHANGED
File without changes
test CHANGED
@@ -134,9 +134,7 @@
134
134
 
135
135
  if (req.query.p) {
136
136
 
137
- id = req.query.p;
138
-
139
- const obj = await getFunc(id);
137
+ const obj = await getFunc(req.query.p);
140
138
 
141
139
  };
142
140
 

1

余計なasync、await削除

2019/01/11 12:52

投稿

police
police

スコア14

test CHANGED
File without changes
test CHANGED
@@ -128,9 +128,9 @@
128
128
 
129
129
 
130
130
 
131
- main = async () => {
131
+ main = () => {
132
132
 
133
- await router.get('/', async (req, res, next) => {
133
+ router.get('/', async (req, res, next) => {
134
134
 
135
135
  if (req.query.p) {
136
136