mercredi 27 mai 2015

Get request Ember.js on Sails.js

I am creating a web application using Sane stack, which uses Ember.js in the client side as a JavaScript framework, and in th server side it uses Sails.js as a node.js framework.

I use also the Jira API REST to get some data, I can for example GET an Issue via the JIRA API REST with sails.js with a simple controller :

//JiraController
    module.exports = {

            loadProject : function(req, res){

            console.log("Jira contoller");
            var Http = require('machinepack-http');
             process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
             Http.sendHttpRequest({
            url: '/rest/api/2/project/',
            baseUrl: 'http://ift.tt/1PN51s1',
            method: 'get',

            headers: {
              "Authorization": "Basic YWxhYS5lbG90bWFuaTphbGFhNDE0NA=="
            },

            }).exec({

            serverError: function(result) {
            res.send("server error" + JSON.stringify(result));
            },

            success: function(result) {
              res.send("Projects loaded succefly");
            }
            });
            }

    };

In config/routes : I add :

'get /projects' : 'JiraController.loadProject'

I want to get the Issue data in the client side with Ember.js, in other words i want that sails.js request the JIRA API Rest, and then pass the data (JSON) to Ember.js which will display it in a View.

How can I do that please !?




Aucun commentaire:

Enregistrer un commentaire