mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-17 03:01:21 +00:00
fix: dont call callback before it's properly set
This commit is contained in:
@ -24,10 +24,6 @@ module.exports = (node) => {
|
||||
* @returns {void}
|
||||
*/
|
||||
findProviders: (key, options, callback) => {
|
||||
if (!routers.length) {
|
||||
return callback(errCode(new Error('No content routers available'), 'NO_ROUTERS_AVAILABLE'))
|
||||
}
|
||||
|
||||
if (typeof options === 'function') {
|
||||
callback = options
|
||||
options = {}
|
||||
@ -37,6 +33,10 @@ module.exports = (node) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (!routers.length) {
|
||||
return callback(errCode(new Error('No content routers available'), 'NO_ROUTERS_AVAILABLE'))
|
||||
}
|
||||
|
||||
const tasks = routers.map((router) => {
|
||||
return (cb) => router.findProviders(key, options, (err, results) => {
|
||||
if (err) {
|
||||
|
Reference in New Issue
Block a user