Json return error {"isFulfilled": false, "isRejected": false} + Node

1

I have the following code on the node:

 var express = require('express');
    var app = express();
    
    app.get('/api/events', function(req, res, next) {
        var events = repositorio.ListAll();
        res.json(events); 
    })
      
    app.get('*', function(req, res) {
        res.sendfile('./public/index.html');
    });
     
    app.listen(9000);

But I perform the same query returns me on screen:

{"isFulfilled": false, "isRejected": false}

My repository.ListAll () method looks like this:

  ListAll : function (){
    return event.findAll().then(function(eventCTX) {
      eventCTX
    });
  },
    
asked by anonymous 29.04.2017 / 18:12

1 answer

0

Looking at your code I see that event.findAll() generates a Promise. So you'd have return event.findAll() without .then() and then use it like this:

app.get('/api/events', function(req, res, next) {
    repositorio.ListAll().then(ev => res.json(ev))
})
    
02.05.2017 / 07:20