examples
examples copied to clipboard
Failing with "Parameter 'url' must be a string, not undefined"
Hi, I am new to Serverless and Node.js. I am trying to run the "aws-node-fetch-file-and-store-in-s3" example. I have not modified the code. Here is how I am invoking it.
serverless invoke -f save -l -d "{'image_url':'https://assets-cdn.github.com/images/modules/open_graph/github-mark.png','key':'github.png'}"
I am getting the following error message.
{
"errorMessage": "Parameter 'url' must be a string, not undefined",
"errorType": "TypeError",
"stackTrace": [
"Url.parse (url.js:90:11)",
"urlParse (url.js:84:5)",
"Body.Request (/var/task/node_modules/node-fetch/lib/request.js:27:16)",
"/var/task/node_modules/node-fetch/index.js:51:17",
"new Fetch (/var/task/node_modules/node-fetch/index.js:49:9)",
"Fetch (/var/task/node_modules/node-fetch/index.js:37:10)",
"module.exports.save.fetch.then.then.response.then.buffer.then (/var/task/handler.
js:9:3)"
]
}
I guess I am doing a silly error, but I am not able to get rid of it. Please help.
Thanks in advance.
Does it work if you use the example command in the README?
https://github.com/serverless/examples/tree/master/aws-node-fetch-file-and-store-in-s3#usage
Nope. I am working on a windows machine. If I use the mentioned command directly I get the following error:
ServerlessError: Serverless command "invoke image_url:" not found
This seems to be a quoting issue. According to a quick search, the default windows command prompt seems to have weird quoting behaviour. Maybe try powershell instead?
I am also getting the same error : ServerlessError: Serverless command "invoke image_url:" not found
@christophgysin, I don't think it is a quote issue (I modified the quote to ensure it is working on Windows cmd prompt). I tried Powershell and it is allowing me to use the command as documented in the example.
However, once past the quote issue, I hit the same problem - the error message in my original post. Where is it expecting the parameter 'url'? Why is it 'undefined'? As noted in my original post, I have not modified the code.
The stacktrace shows you where it fails:
"module.exports.save.fetch.then.then.response.then.buffer.then (/var/task/handler.js:9:3)"
Which is the line:
fetch(event.image_url)
So it seems that image_url
is undefined, hence my assumption that the parameter is not correctly passed due to quoting. You could print the whole event
object to the console and check the log to see if the image_url
parameter was passed correctly.
I'm having the same issue with undefined as well, maybe a complete noob question but how is the "image_url" supposed to be defined?
This is not the same issue. Please double check the example command in the README: https://github.com/serverless/examples/tree/master/aws-node-fetch-file-and-store-in-s3#usage