From 7c3de6c149810537171a9c731d7848bf58c27f2a Mon Sep 17 00:00:00 2001 From: Dillon Kearns Date: Tue, 21 Dec 2021 16:11:51 -0800 Subject: [PATCH] Remove hardcoded query params in adapter. --- examples/pokedex/adapter.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/pokedex/adapter.js b/examples/pokedex/adapter.js index 8ca91617..13e62fc4 100644 --- a/examples/pokedex/adapter.js +++ b/examples/pokedex/adapter.js @@ -188,11 +188,17 @@ async function render(event, context) { * @returns {{ method: string; hostname: string; query: string; headers: Object; host: string; pathname: string; port: number | null; protocol: string; rawUrl: string; }} */ function reqToJson(req) { + const queryString = req.multiValueQueryStringParameters ? Object.entries(req.multiValueQueryStringParameters).reduce( + (acc, [key, values]) => { + return acc + values.map(value => \`\${encodeURIComponent(key)}=\${encodeURIComponent(value)}\`).join('&') + } + , "") : ''; + + return { method: req.httpMethod, hostname: "TODO", - // query: req.queryStringParameters, //url.search ? url.search.substring(1) : "", - query: "", //url.search ? url.search.substring(1) : "", + query: queryString, headers: req.headers, host: "", // TODO pathname: req.path,