I have a small chatbot, which reacts to the word: "test". On reading this word, he is supposed to call an IBM Cloud Function which in return tries to register the user returning a token. The Problem is, that the authentication API takes about 30s to respond and the IBM Cloud function executes immediately. So my response is always like this
{
"body": {},
"headers": {"Content-Type": "application/json" },
"status": 200
}
But it should actually return the token in the body
{
"body": { "token": ... },
...
}
I have already tried setting the timeout to 5min, but this did not help. I tried aswell in Postman, there I get the correct response. Then I exported the request for javascript and modified it to work in the Cloud Function but again it returns an empty body.
var request = require("request");
function main({id=123}) {
var options = { method: 'POST',
url: 'ip:port/v1/authentication',
headers:
{
"Host": "ip:port",
"Content-Type": "application/json" },
body: { username: '---', password: '---' },
json: true };
var result = { error: "No result was received" };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(`Response body is: ${response.body}`);
result = { token: response.body.token };
});
return {
statusCode: 200,
headers: { "Content-Type": "application/json" },
body: { token: result["token"] }
};
}
And below you can see the messages I get
Activation ID:
...
Results:
{
"body": {},
"headers": {
"Content-Type": "application/json"
},
"statusCode": 200
}
Logs:
[]
Sadly the logs show no error message since everything is logically working.