質問編集履歴
2
検証を追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -122,6 +122,18 @@
|
|
122
122
|
|
123
123
|
原因と対策方法がわからないので教えていただきたいです
|
124
124
|
|
125
|
+
### 追記
|
126
|
+
|
127
|
+
response.confing.data
|
128
|
+
|
129
|
+
としてconsole.logをしたらターミナル上に想定していた値が返ってきました。
|
130
|
+
|
131
|
+
しかしaxios.getしてもundefinedとなり値を取得できませんなぜでしょうか?
|
132
|
+
|
133
|
+
nodeではaxiosが使えないなんてことがあるのでしょうか?
|
134
|
+
|
135
|
+
|
136
|
+
|
125
137
|
```ここに言語を入力
|
126
138
|
|
127
139
|
いけてる {
|
1
検証を追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -108,6 +108,454 @@
|
|
108
108
|
|
109
109
|
|
110
110
|
|
111
|
+
console.log('いけてる',response.data);
|
112
|
+
|
113
|
+
を
|
114
|
+
|
115
|
+
### 解決の糸口になりそうなこと
|
116
|
+
|
117
|
+
console.log('いけてる',response);
|
118
|
+
|
119
|
+
にしたら下のようになり一応反映されていることがわかります
|
120
|
+
|
121
|
+
ただ、dataが2個あってresponse.dataとするとhtmlの方が出力されてしまいます。
|
122
|
+
|
123
|
+
原因と対策方法がわからないので教えていただきたいです
|
124
|
+
|
125
|
+
```ここに言語を入力
|
126
|
+
|
127
|
+
いけてる {
|
128
|
+
|
129
|
+
status: 200,
|
130
|
+
|
131
|
+
statusText: 'OK',
|
132
|
+
|
133
|
+
headers: {
|
134
|
+
|
135
|
+
'x-powered-by': 'Express',
|
136
|
+
|
137
|
+
'content-type': 'text/html; charset=utf-8',
|
138
|
+
|
139
|
+
'content-length': '1276',
|
140
|
+
|
141
|
+
etag: 'W/"4fc-Xi7sOKe6PVfU4AVFFZ0dEggSnUU"',
|
142
|
+
|
143
|
+
'set-cookie': [
|
144
|
+
|
145
|
+
'connect.sid=s%3AnbeFFjUiZPlLupsF0KPtLc8j7GMxiuys.QKRAXjuBS6zXTQq8qOQi1vFe%2BDF1frGoXvIR0tlj8xU; Path=/; HttpOnly'
|
146
|
+
|
147
|
+
],
|
148
|
+
|
149
|
+
date: 'Sun, 17 Jan 2021 16:25:25 GMT',
|
150
|
+
|
151
|
+
connection: 'close'
|
152
|
+
|
153
|
+
},
|
154
|
+
|
155
|
+
config: {
|
156
|
+
|
157
|
+
url: '/message',
|
158
|
+
|
159
|
+
method: 'post',
|
160
|
+
|
161
|
+
data: '{"firstName":"Yohei","lastName":"Munesada"}',
|
162
|
+
|
163
|
+
headers: {
|
164
|
+
|
165
|
+
Accept: 'application/json, text/plain, */*',
|
166
|
+
|
167
|
+
'User-Agent': 'axios/0.21.1'
|
168
|
+
|
169
|
+
},
|
170
|
+
|
171
|
+
baseURL: 'http://localhost:3000',
|
172
|
+
|
173
|
+
transformRequest: [ [Function: transformRequest] ],
|
174
|
+
|
175
|
+
transformResponse: [ [Function: transformResponse] ],
|
176
|
+
|
177
|
+
timeout: 0,
|
178
|
+
|
179
|
+
adapter: [Function: httpAdapter],
|
180
|
+
|
181
|
+
responseType: 'json',
|
182
|
+
|
183
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
184
|
+
|
185
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
186
|
+
|
187
|
+
maxContentLength: -1,
|
188
|
+
|
189
|
+
maxBodyLength: -1,
|
190
|
+
|
191
|
+
validateStatus: [Function: validateStatus]
|
192
|
+
|
193
|
+
},
|
194
|
+
|
195
|
+
request: <ref *1> ClientRequest {
|
196
|
+
|
197
|
+
_events: [Object: null prototype] {
|
198
|
+
|
199
|
+
socket: [Function (anonymous)],
|
200
|
+
|
201
|
+
abort: [Function (anonymous)],
|
202
|
+
|
203
|
+
aborted: [Function (anonymous)],
|
204
|
+
|
205
|
+
connect: [Function (anonymous)],
|
206
|
+
|
207
|
+
error: [Function (anonymous)],
|
208
|
+
|
209
|
+
timeout: [Function (anonymous)],
|
210
|
+
|
211
|
+
prefinish: [Function: requestOnPrefinish]
|
212
|
+
|
213
|
+
},
|
214
|
+
|
215
|
+
_eventsCount: 7,
|
216
|
+
|
217
|
+
_maxListeners: undefined,
|
218
|
+
|
219
|
+
outputData: [],
|
220
|
+
|
221
|
+
outputSize: 0,
|
222
|
+
|
223
|
+
writable: true,
|
224
|
+
|
225
|
+
destroyed: false,
|
226
|
+
|
227
|
+
_last: true,
|
228
|
+
|
229
|
+
chunkedEncoding: false,
|
230
|
+
|
231
|
+
shouldKeepAlive: false,
|
232
|
+
|
233
|
+
_defaultKeepAlive: true,
|
234
|
+
|
235
|
+
useChunkedEncodingByDefault: false,
|
236
|
+
|
237
|
+
sendDate: false,
|
238
|
+
|
239
|
+
_removedConnection: false,
|
240
|
+
|
241
|
+
_removedContLen: false,
|
242
|
+
|
243
|
+
_removedTE: false,
|
244
|
+
|
245
|
+
_contentLength: 0,
|
246
|
+
|
247
|
+
_hasBody: true,
|
248
|
+
|
249
|
+
_trailer: '',
|
250
|
+
|
251
|
+
finished: true,
|
252
|
+
|
253
|
+
_headerSent: true,
|
254
|
+
|
255
|
+
socket: Socket {
|
256
|
+
|
257
|
+
connecting: false,
|
258
|
+
|
259
|
+
_hadError: false,
|
260
|
+
|
261
|
+
_parent: null,
|
262
|
+
|
263
|
+
_host: 'localhost',
|
264
|
+
|
265
|
+
_readableState: [ReadableState],
|
266
|
+
|
267
|
+
_events: [Object: null prototype],
|
268
|
+
|
269
|
+
_eventsCount: 7,
|
270
|
+
|
271
|
+
_maxListeners: undefined,
|
272
|
+
|
273
|
+
_writableState: [WritableState],
|
274
|
+
|
275
|
+
allowHalfOpen: false,
|
276
|
+
|
277
|
+
_sockname: null,
|
278
|
+
|
279
|
+
_pendingData: null,
|
280
|
+
|
281
|
+
_pendingEncoding: '',
|
282
|
+
|
283
|
+
server: null,
|
284
|
+
|
285
|
+
_server: null,
|
286
|
+
|
287
|
+
parser: null,
|
288
|
+
|
289
|
+
_httpMessage: [Circular *1],
|
290
|
+
|
291
|
+
[Symbol(async_id_symbol)]: 289,
|
292
|
+
|
293
|
+
[Symbol(kHandle)]: [TCP],
|
294
|
+
|
295
|
+
[Symbol(kSetNoDelay)]: false,
|
296
|
+
|
297
|
+
[Symbol(lastWriteQueueSize)]: 0,
|
298
|
+
|
299
|
+
[Symbol(timeout)]: null,
|
300
|
+
|
301
|
+
[Symbol(kBuffer)]: null,
|
302
|
+
|
303
|
+
[Symbol(kBufferCb)]: null,
|
304
|
+
|
305
|
+
[Symbol(kBufferGen)]: null,
|
306
|
+
|
307
|
+
[Symbol(kCapture)]: false,
|
308
|
+
|
309
|
+
[Symbol(kBytesRead)]: 0,
|
310
|
+
|
311
|
+
[Symbol(kBytesWritten)]: 0,
|
312
|
+
|
313
|
+
[Symbol(RequestTimeout)]: undefined
|
314
|
+
|
315
|
+
},
|
316
|
+
|
317
|
+
_header: 'GET /organizer-login HTTP/1.1\r\n' +
|
318
|
+
|
319
|
+
'Accept: application/json, text/plain, */*\r\n' +
|
320
|
+
|
321
|
+
'User-Agent: axios/0.21.1\r\n' +
|
322
|
+
|
323
|
+
'Host: localhost:3000\r\n' +
|
324
|
+
|
325
|
+
'Connection: close\r\n' +
|
326
|
+
|
327
|
+
'\r\n',
|
328
|
+
|
329
|
+
_keepAliveTimeout: 0,
|
330
|
+
|
331
|
+
_onPendingData: [Function: noopPendingOutput],
|
332
|
+
|
333
|
+
agent: Agent {
|
334
|
+
|
335
|
+
_events: [Object: null prototype],
|
336
|
+
|
337
|
+
_eventsCount: 2,
|
338
|
+
|
339
|
+
_maxListeners: undefined,
|
340
|
+
|
341
|
+
defaultPort: 80,
|
342
|
+
|
343
|
+
protocol: 'http:',
|
344
|
+
|
345
|
+
options: [Object],
|
346
|
+
|
347
|
+
requests: {},
|
348
|
+
|
349
|
+
sockets: [Object],
|
350
|
+
|
351
|
+
freeSockets: {},
|
352
|
+
|
353
|
+
keepAliveMsecs: 1000,
|
354
|
+
|
355
|
+
keepAlive: false,
|
356
|
+
|
357
|
+
maxSockets: Infinity,
|
358
|
+
|
359
|
+
maxFreeSockets: 256,
|
360
|
+
|
361
|
+
scheduling: 'fifo',
|
362
|
+
|
363
|
+
maxTotalSockets: Infinity,
|
364
|
+
|
365
|
+
totalSocketCount: 1,
|
366
|
+
|
367
|
+
[Symbol(kCapture)]: false
|
368
|
+
|
369
|
+
},
|
370
|
+
|
371
|
+
socketPath: undefined,
|
372
|
+
|
373
|
+
method: 'GET',
|
374
|
+
|
375
|
+
maxHeaderSize: undefined,
|
376
|
+
|
377
|
+
insecureHTTPParser: undefined,
|
378
|
+
|
379
|
+
path: '/organizer-login',
|
380
|
+
|
381
|
+
_ended: true,
|
382
|
+
|
383
|
+
res: IncomingMessage {
|
384
|
+
|
385
|
+
_readableState: [ReadableState],
|
386
|
+
|
387
|
+
_events: [Object: null prototype],
|
388
|
+
|
389
|
+
_eventsCount: 3,
|
390
|
+
|
391
|
+
_maxListeners: undefined,
|
392
|
+
|
393
|
+
socket: [Socket],
|
394
|
+
|
395
|
+
httpVersionMajor: 1,
|
396
|
+
|
397
|
+
httpVersionMinor: 1,
|
398
|
+
|
399
|
+
httpVersion: '1.1',
|
400
|
+
|
401
|
+
complete: true,
|
402
|
+
|
403
|
+
headers: [Object],
|
404
|
+
|
405
|
+
rawHeaders: [Array],
|
406
|
+
|
407
|
+
trailers: {},
|
408
|
+
|
409
|
+
rawTrailers: [],
|
410
|
+
|
411
|
+
aborted: false,
|
412
|
+
|
413
|
+
upgrade: false,
|
414
|
+
|
415
|
+
url: '',
|
416
|
+
|
417
|
+
method: null,
|
418
|
+
|
419
|
+
statusCode: 200,
|
420
|
+
|
421
|
+
statusMessage: 'OK',
|
422
|
+
|
423
|
+
client: [Socket],
|
424
|
+
|
425
|
+
_consuming: false,
|
426
|
+
|
427
|
+
_dumped: false,
|
428
|
+
|
429
|
+
req: [Circular *1],
|
430
|
+
|
431
|
+
responseUrl: 'http://localhost:3000/organizer-login',
|
432
|
+
|
433
|
+
redirects: [],
|
434
|
+
|
435
|
+
[Symbol(kCapture)]: false,
|
436
|
+
|
437
|
+
[Symbol(RequestTimeout)]: undefined
|
438
|
+
|
439
|
+
},
|
440
|
+
|
441
|
+
aborted: false,
|
442
|
+
|
443
|
+
timeoutCb: null,
|
444
|
+
|
445
|
+
upgradeOrConnect: false,
|
446
|
+
|
447
|
+
parser: null,
|
448
|
+
|
449
|
+
maxHeadersCount: null,
|
450
|
+
|
451
|
+
reusedSocket: false,
|
452
|
+
|
453
|
+
host: 'localhost',
|
454
|
+
|
455
|
+
protocol: 'http:',
|
456
|
+
|
457
|
+
_redirectable: Writable {
|
458
|
+
|
459
|
+
_writableState: [WritableState],
|
460
|
+
|
461
|
+
_events: [Object: null prototype],
|
462
|
+
|
463
|
+
_eventsCount: 2,
|
464
|
+
|
465
|
+
_maxListeners: undefined,
|
466
|
+
|
467
|
+
_options: [Object],
|
468
|
+
|
469
|
+
_ended: true,
|
470
|
+
|
471
|
+
_ending: true,
|
472
|
+
|
473
|
+
_redirectCount: 1,
|
474
|
+
|
475
|
+
_redirects: [],
|
476
|
+
|
477
|
+
_requestBodyLength: 43,
|
478
|
+
|
479
|
+
_requestBodyBuffers: [],
|
480
|
+
|
481
|
+
_onNativeResponse: [Function (anonymous)],
|
482
|
+
|
483
|
+
_currentRequest: [Circular *1],
|
484
|
+
|
485
|
+
_currentUrl: 'http://localhost:3000/organizer-login',
|
486
|
+
|
487
|
+
_isRedirect: true,
|
488
|
+
|
489
|
+
[Symbol(kCapture)]: false
|
490
|
+
|
491
|
+
},
|
492
|
+
|
493
|
+
[Symbol(kCapture)]: false,
|
494
|
+
|
495
|
+
[Symbol(kNeedDrain)]: false,
|
496
|
+
|
497
|
+
[Symbol(corked)]: 0,
|
498
|
+
|
499
|
+
[Symbol(kOutHeaders)]: [Object: null prototype] {
|
500
|
+
|
501
|
+
accept: [Array],
|
502
|
+
|
503
|
+
'user-agent': [Array],
|
504
|
+
|
505
|
+
host: [Array]
|
506
|
+
|
507
|
+
}
|
508
|
+
|
509
|
+
},
|
510
|
+
|
511
|
+
data: '<!DOCTYPE html>\n' +
|
512
|
+
|
513
|
+
'<html lang="ja">\n' +
|
514
|
+
|
515
|
+
'\n' +
|
516
|
+
|
517
|
+
' <head>\n' +
|
518
|
+
|
519
|
+
' <meta charset="UTF-8">\n' +
|
520
|
+
|
521
|
+
' <meta name="viewport" content="width=device-width, initial-scale=1.0">\n' +
|
522
|
+
|
523
|
+
' <meta http-equiv="X-UA-Compatible" content="ie=edge">\n' +
|
524
|
+
|
525
|
+
` <link rel="stylesheet" href='/stylesheets/organizer-login.css'>\n` +
|
526
|
+
|
527
|
+
' <title>sign-up</title>\n' +
|
528
|
+
|
529
|
+
'</head>\n' +
|
530
|
+
|
531
|
+
'\n' +
|
532
|
+
|
533
|
+
'\n' +
|
534
|
+
|
535
|
+
'\n' +
|
536
|
+
|
537
|
+
'\n' +
|
538
|
+
|
539
|
+
'\n' +
|
540
|
+
|
541
|
+
'<body>\n' +
|
542
|
+
|
543
|
+
' ~~~~~~~~~~~~~~省略~~~~~~~~~~~~~~~~~
|
544
|
+
|
545
|
+
'</body>\n' +
|
546
|
+
|
547
|
+
'\n' +
|
548
|
+
|
549
|
+
'</html>'
|
550
|
+
|
551
|
+
}
|
552
|
+
|
553
|
+
|
554
|
+
|
555
|
+
```
|
556
|
+
|
557
|
+
|
558
|
+
|
111
559
|
function useaxios以外に
|
112
560
|
|
113
561
|
res.render('message',Data)としてresponseを使用しているからおかしな値が返ってくるのかなと考えましたがいかがでしょうか?
|