When I use postman to call my lambda function invoked by APIgateway, it returns the result, but through SDK I always get exception with status 0. I'm not sure how I should be returning my result from lambda to work with SDK. This is what I have in my lambda function which works fine and returns expected value using postman.
return {
'statusCode': 200,
'headers': {
'Content-Type': 'text/html',
},
'body': htmlStr
}
but in SDK it messes up, here's my code:
var body = {
"id": REST_DATA.selectedPatId,
"date": JSON.parse(record.sleepdata).Start_Date,
"starttime":JSON.parse(record.sleepdata).Start_Time,
"user":REST_DATA.restTrackerLoginUser
};
var additionalParams = {
headers: {
'Content-Type': 'text/html',
},
};
apigClient.spectogramPost(null, body, additionalParams)
.then(function(result){
debugger;
// Add success callback code here.
}).catch( function(result){
// ALWAYS COMES HERE
});
{data: '', status: 0, statusText: '', headers: {…}, config: {…}}
config
:
{method: 'POST', headers: {…}, timeout: 0, transformRequest: Array(1), transformResponse: Array(1), …}
data
:
""
headers
:
{}
status
:
0
statusText
:
""