The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

codergurl (3) [Avatar] Offline
#1
When I test the lambda function returning the html, I get the following response, instead of the body with the html. Any suggestions or ideas why?

Response:
{
"statusCode": 200,
"body": {
"type": "Buffer",
"data": [
60,
104,
116,
109,
108,
62,
10,
32,
32,
60,
98,
111,
100,
121,
62,
10,
32,
32,
32,
32,
72,
101,
108,
108,
111,
32,
102,
114,
111,
109,
32,
76,
97,
109,
98,
100,
97,
10,
32,
32,
60,
47,
98,
111,
100,
121,
62,
10,
60,
47,
104,
116,
109,
108,
62,
10
]
},
"headers": {
"Content-Type": "text/html; charset=UTF-8"
}
}

Request ID:
"99f950c7-9857-11e8-98ee-670154895461"

Function Logs:
START RequestId: 99f950c7-9857-11e8-98ee-670154895461 Version: $LATEST
END RequestId: 99f950c7-9857-11e8-98ee-670154895461
REPORT RequestId: 99f950c7-9857-11e8-98ee-670154895461 Duration: 0.50 ms Billed Duration: 100 ms Memory Size: 1024 MB
codergurl (3) [Avatar] Offline
#2
I updated my code to nodejs8.10 and updated it to use async await - and now it all works.
Yan Cui (73) [Avatar] Offline
#3
Hi, could you paste your get-index function in a gist? The function should work as it was, when we load the HTML we already decoded as utf-8, so when we use it to return the response it shouldn't be a buffer but a string instead.

I'm curious why it works by updating to node8 and async-await!
codergurl (3) [Avatar] Offline
#4
I should have, but didn't, save my original code. Next time I run into anything like this, I'll be sure to do that.