Error When using readline question as a await function
up vote
0
down vote
favorite
I wrote this function that get 2 parameter X and Y and return Movies that created between this 2 years. but I get an error that says to me :
UnhandledPromiseRejectionWarning: CastError: Cast to number failed for value "undefined" at path "year" for model "movie"
and this is my function :
async function returnMoviesBetweenXandY(){
const X = await rl.question('enter the first number : ')
const Y = await rl.question('enter the second number : ')
const a = await Movie.find({}).sort('-year').where('year').gt(X).lt(Y).sort('rank')
const temp =await Promise.map(a, getTitle)
return X;
}
returnMoviesBetweenXandY().then(function(result){console.log(result)})
what is wrong in my code?
node.js mongoose
add a comment |
up vote
0
down vote
favorite
I wrote this function that get 2 parameter X and Y and return Movies that created between this 2 years. but I get an error that says to me :
UnhandledPromiseRejectionWarning: CastError: Cast to number failed for value "undefined" at path "year" for model "movie"
and this is my function :
async function returnMoviesBetweenXandY(){
const X = await rl.question('enter the first number : ')
const Y = await rl.question('enter the second number : ')
const a = await Movie.find({}).sort('-year').where('year').gt(X).lt(Y).sort('rank')
const temp =await Promise.map(a, getTitle)
return X;
}
returnMoviesBetweenXandY().then(function(result){console.log(result)})
what is wrong in my code?
node.js mongoose
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I wrote this function that get 2 parameter X and Y and return Movies that created between this 2 years. but I get an error that says to me :
UnhandledPromiseRejectionWarning: CastError: Cast to number failed for value "undefined" at path "year" for model "movie"
and this is my function :
async function returnMoviesBetweenXandY(){
const X = await rl.question('enter the first number : ')
const Y = await rl.question('enter the second number : ')
const a = await Movie.find({}).sort('-year').where('year').gt(X).lt(Y).sort('rank')
const temp =await Promise.map(a, getTitle)
return X;
}
returnMoviesBetweenXandY().then(function(result){console.log(result)})
what is wrong in my code?
node.js mongoose
I wrote this function that get 2 parameter X and Y and return Movies that created between this 2 years. but I get an error that says to me :
UnhandledPromiseRejectionWarning: CastError: Cast to number failed for value "undefined" at path "year" for model "movie"
and this is my function :
async function returnMoviesBetweenXandY(){
const X = await rl.question('enter the first number : ')
const Y = await rl.question('enter the second number : ')
const a = await Movie.find({}).sort('-year').where('year').gt(X).lt(Y).sort('rank')
const temp =await Promise.map(a, getTitle)
return X;
}
returnMoviesBetweenXandY().then(function(result){console.log(result)})
what is wrong in my code?
node.js mongoose
node.js mongoose
asked Nov 8 at 11:10
Fahom
235
235
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206549%2ferror-when-using-readline-question-as-a-await-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown