allcount/allcountjs

Call Rest APIs from allcountjs

bdqnghi opened this issue · 2 comments

I have some existing Rest APIs that provide some information and I want to integrate Allcountjs with my APIs, how can I call it from inside an AllcountJS app?

I solved this with hack:
First, I added into node_modules/allcountjs/core/index.js few lines:

//In the beginning
var request = require('request');
...
function configure() {
    .... 
    injection.bindFactory('Request', function () {
        return request;
    });

Then, in configuration file:

        beforeSave: function (Entity, Crud, Console, ValidationError, Request) {
          return new Promise(resolv => {
          Request.get('http://127.0.0.1:5555', x => {
            resolv();
          })
        })