I have this code below, using the npm.js api request
let inputContent = {
prompt: req.body.prompt
}
inputContent.prompt = JSON.stringify(inputContent.prompt)
request.post({
url: 'https://my.api.com/',
headers : {
"content-type": "application/json",
},
body: {
"prompt": inputContent.prompt,
"max_tokens": 4000
},
json: true
}, function(err, httpResponse, body) {
if (err) {
console.log(err)
} else {
console.log("body response is")
console.log(body)
}
})
I expect a response through body, but it keeps returning undefined. I also tried using form instead of body, and i tried removing json. Could anyone offer some advice?