Hello,
I’m not able to manage HasNext() after a function.
If I use this code it works:
wixData . query ( ‘DB’ ). eq ( ‘active’ , true )
. ne ( “lost” , true )
. limit ( 4 )
. find ()
. then ( ( resultsSearch ) => {
let result = resultsSearch ;
let hasNext = result . hasNext ();
let hasPrev = result . hasPrev ();
if ( hasNext ) {
$w ( ‘#Bnext’ ). enable ();
}
if ( hasPrev ) {
$w ( ‘#Bback’ ). enable ();
}
})
If I put the same query in a function and then I call the function from a .jsw file, it does not work since it prints that HasNext() is not a function.
I’ve checked and the function is working properly with correct results.
//inside jsw file -
export function get_Record ( ) {
return wixData . query ( ‘DB’ ). eq ( ‘active’ , true )
. ne ( “lots” , true )
. limit ( 4 )
. find ()
}
// inside jsw file +
let resultsSearch = await get_Record;
**let** result = resultsSearch ;
**let** hasNext = result . hasNext ();
**let** hasPrev = result . hasPrev ();
**if** ( hasNext ) {
$w ( '#Bnext' ). enable ();
}
**if** ( hasPrev ) {
$w ( '#Bback' ). enable ();
}
})
Thanks for your help!
David