Getting Error when running on lamda
I am running the Nightmare locally using Xquartz path on my mac and everything is working fine but when I deploy it on lamda it is throwing error without any error detail just getting blank object in error.
Here is my code:-
nightmarePromise = nightmare
.useragent(AGENT_NAME)
.goto(params.url)
.then(function(response){
if(!response || !response.code || response.code != 200){
const error = {
error: true
, statusCode: response.code
, message: 'An error occured getting dom content.'
, detail: response
, url: params.url
}
callback(error, data);
}else{
return nightmare
.wait(7000)
.evaluate(function () {
return document.documentElement.outerHTML;
})
.end();
}
})
.catch(function(err){
const error = {
error: true
, statusCode: 400
, message: "An error occured getting dom and caught here in the code."
, detail: err
, url: params.url
}
callback(error, data);
});
On lamda everytime I am thrown into catch blog with {} this as error ,Am I missing something or any misconfiguration I had did for this and mostly it is failing for url styarting with http://
To make it work on Lambda, you have to make sure you wrap your code inside this "boiler plate" template (as described in the README https://github.com/dimkir/nightmare-lambda-tutorial#write-your-lambda-function-source-code)
Be sure to read Quickstart as there's a significant amount of plumbing to make it transferrable from your local environment to lambda