I was going to call third party api in the aws lambda function with request. But it shows timeout error. I set the lambda function time 30s and when I call that api by using postman it send response(error) with in 5 seconds. I think the request or axios can't send the request to the external api or can't receive the response. Can anyone help me? My code:
request.post({url:url2, json:true, body:body, headers: {
'ACCESS_TIMESTAMP': timestamp,
'Content-Type': 'application/json'
} }, (error, response, body) => {
console.log("------------------I am here----------------------")
callback(null, error)
})
When I use the axios the code is like below:
let jsonbody = JSON.stringify(body)
axios.post(url2, jsonbody, {headers: {
'ACCESS_TIMESTAMP': timestamp,
'Content-Type': 'application/json'
}})
.then(res => {
callback(null, res.data)
})
.catch(err => {
callback(null, err)
})
I want to get the result of res or err but they don't act.