Coder Social home page Coder Social logo

Cote.js (promise) in Express about cote HOT 5 CLOSED

dashersw avatar dashersw commented on May 21, 2024
Cote.js (promise) in Express

from cote.

Comments (5)

dashersw avatar dashersw commented on May 21, 2024 4

@keramet hello! Actually, it's pretty simple. If you are using promises and callbacks together, you should make sure the first argument in the callback is the error object and it will be passed onto the catch handler, and the second argument is the actual result.

In your case, a simple cb(null, { uuid: uuid() }); would work. On the other hand, you can also use responder.on('uuid', (res) => Promise.resolve({ uuid: uuid() })).

from cote.

robophil avatar robophil commented on May 21, 2024 1

@dashersw I think this should be highlighted more in the readme :-)

from cote.

robophil avatar robophil commented on May 21, 2024

@keramet i don't think you're returning a promise. In your requester, you seem to be expecting one. Try this

   const cote = require('cote'), uuid = require('uuid/v4'),
              responder = new cote.Responder({name: 'uuid Responder'}),
            
   responder.on('uuid', (req) => new Promise( (resolve, reject) => resolve(uuid()) )

from cote.

dashersw avatar dashersw commented on May 21, 2024

I agree :)

from cote.

geka-evk avatar geka-evk commented on May 21, 2024

Thanks, guys!

from cote.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.