node.jsでJSONを送る際に、JSON.stringify(json)を使用してJSON文字列にして送っていますが、こちらは、生JSONのまま送ることはできないのでしょうか?
const https = require('https'); exports.handler = (event, context, callback) => { var key1 = event.key1; var json = {"query": {"key1": key1}} var jsons = JSON.stringify(json);//これが必要。 const options = { protocol: 'https:', host: 'aws.com', path: '/p/at/h', method: 'GET', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(jsons) } }; const req = https.request(options, (res) => { res.setEncoding("utf-8"); res.on('data', (chunk) => { callback(null, `${chunk}`); }); }); req.write(jsons); req.end(); }
上記のソースのjsonをそのままoptions内で書く方法はないでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。