Return task results using firebase-queue

后端 未结 2 2157
清酒与你
清酒与你 2021-01-14 17:39

I am working on a mobile application using Firebase. In the mobile app, I need to register a user based on his/her mobile number similar to Whatsapp. I intend to use Nexmo t

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-14 17:58

    You do not need to write the requestId in the object. Instead, you can use the following code to return a response. I think it is a bit cleaner.

    On the client side: ref.child('queue/tasks').push({foo:'bar'});

    The trick is to not sanitize the input. On the server side:

    var options = {sanitize:false};
    
    queue = new Queue(firebaseQueueRef, options , function(request, progress, resolve, reject){
       //do some work
       setTimeout(function(){
         resposeRef.child(request._id).set(myResponse);
         resolve();
       }
    });
    

提交回复
热议问题