node-georedis | Super fast geo queries | GraphQL library
kandi X-RAY | node-georedis Summary
kandi X-RAY | node-georedis Summary
Super fast geo queries.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of node-georedis
node-georedis Key Features
node-georedis Examples and Code Snippets
Community Discussions
Trending Discussions on node-georedis
QUESTION
I'm building a GraphQL API, where I need to access nearby users locations. I using the node-georedis lib (https://github.com/arjunmehta/node-georedis), which takes callbacks in order to get return data.
I can verify that the callback does indeed get called with the correct information returned, however when I then try to return that data in the GraphQL query resolver it's undefined. I figured it was an asynchronous issue, but I've tried various Promise based, await/async, and even a synchronous implementations after searching stackoverflow with no success.
Maybe I'm overlooking a scope issue?? Any thoughts would be greatly appreciated!
...ANSWER
Answered 2018-Jun-14 at 23:19export const nearbyUsers = (latitude: Number, longitude: Number) => {
return new Promise((resolve, reject) => {
georedis.nearby({ latitude, longitude }, 5000, (err: any, userIDS: any) => {
err ? reject(err) : resolve(userIDS);
});
}).then(async (userIDS) => {
return User.findByIds(userIDS as string[]);
});
};
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install node-georedis
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page