no, not from client.

every request comes with a response object to you, and you have to respond 
to every request:

module.exports = function (app) {
    var Client = require('node-rest-client').Client;

    app.put('/api/provisions/', function (req, serverRes) {

        console.log("provisions prov:" + JSON.stringify(req.body.prov))
        console.log("provisions id:" + JSON.stringify(req.body.id))

        var client = new Client();

        var args = {
            path: '/api/'+ data.body.id,
            port: 443,
            headers: {'Authorization': 'Bearer  xxxxxxxxx'},
            data: {'restrictions': data.body.prov}
        };

        console.log('args.data:' + JSON.stringify(args.data))

        client.put("https://hostsite.com";, args, function (data, 
clientResponse) {
            console.log(data);
            *serverRes.send(200, data)*
        });

    });
}

Am Montag, 3. März 2014 14:40:36 UTC+1 schrieb Josh Longbrake:
>
> Thanks for the info.  The pending is showing in my angular put, as the 
> node request is never returned.  Does the res.send come within client.put? 
>
> client.put("https://hostsite.com";, args, function (req, res) {
>            // res.send like this?
>         });
>
> //like this?
> app.put('/api/provisions/', function (req, res) {
> On Mar 3, 2014 2:08 AM, "greelgorke" <greel...@gmail.com <javascript:>> 
> wrote:
>
>> what is pending? the request from angular to your route handler? or the 
>> rest-client.put request?
>>
>> 1. there is no alert() in node. try console.log
>> 2. you have to do something with your reoute handler. i assume you are 
>> using express on server side. your route handler gets 2 params: request and 
>> response. (the thing you named data is the reqeust object.) when you are 
>> done with anything in your route handler you have to do something to 
>> respond to the client: res.send or something like that.
>>
>> Am Freitag, 28. Februar 2014 22:58:06 UTC+1 schrieb Josh Longbrake:
>>>
>>> I have been unable to complete this request, using a few different 
>>> options, none of which are working as I believe implementation is 
>>> incorrect.  How do I get the request through?
>>>
>>> my request:
>>>
>>>     http{
>>>         host: 'hostsite.com',
>>>         port: 443, 
>>>         data: data.body.prov,
>>>         path: '/api/3/mdm/devices/'+ data.body.id,
>>>         method: 'PUT',
>>>         headers: {'Authorization': 'Bearer xxxxxxxxx'}
>>>     }
>>>
>>>
>>> It is constructed as such:
>>>
>>>
>>> AngularJS controller:
>>>
>>> $scope.provisionRule = function (rule) {
>>>             var dataToPass = {prov: rule.newProvisions, id: 
>>> $scope.deviceId};
>>>
>>>             Rules.provision(dataToPass)
>>>                     .success(function (data) {
>>>                         console.log('provision success')
>>>                         console.log(data);
>>>                     });
>>> }
>>>
>>> AngularJS factory:
>>>
>>> angular.module('ruleService', [])
>>>
>>>     .factory('Rules', function($http) {
>>>         return {
>>>             provision : function(data) {
>>>                 console.log('provision: ' + data)
>>>                 return $http.put('/api/provisions/', data);
>>>             }
>>>         }
>>>     });
>>>
>>> node.js:
>>>
>>> module.exports = function (app) {
>>>     //this is not correct syntax but what I am needing to accomplish
>>>
>>>     app.put('/api/provisions/', function (data) {
>>>
>>>         console.log("provisions prov:" + JSON.stringify(data.body.prov))
>>>         console.log("provisions id:" + JSON.stringify(data.body.id))
>>>
>>>     http{
>>>         host: 'hostsite.com',
>>>         port: 443, 
>>>         data: data.body.prov,
>>>         path: '/api/+ data.body.id,
>>>         method: 'PUT',
>>>         headers: {'Authorization': 'Bearer xxxxxxxxx'}
>>>     }
>>> }
>>>
>>>
>>> using this method below I get: 
>>>
>>>    1. Status Code:
>>>    503 Service Unavailable
>>>    
>>>
>>> node.js:
>>> module.exports = function (app) {
>>>
>>>     var Client = require('node-rest-client').Client;
>>>
>>>     app.put('/api/provisions/', function (data) {
>>>
>>>         console.log("provisions prov:" + JSON.stringify(data.body.prov))
>>>         console.log("provisions id:" + JSON.stringify(data.body.id))
>>>
>>>         var client = new Client();
>>>
>>>         var args = {
>>>             path: '/api/'+ data.body.id,
>>>             port: 443,
>>>             headers: {'Authorization': 'Bearer  xxxxxxxxx'},
>>>             data: {'restrictions': data.body.prov}
>>>         };
>>>
>>>         console.log('args.data:' + JSON.stringify(args.data))
>>>
>>>         client.put("https://hostsite.com";, args, function (data, 
>>> response) {
>>>             alert(data);
>>>         });
>>>
>>>     });
>>> }
>>>
>>>
>>>
>>>
>>> I have been provided the host, port, path and headers Bearer.  While the 
>>> above is not the actual provided info, it is a representation of such.  My 
>>> status just hangs in pending.
>>> Any and all help is greatly appreciated as Im banging my head here...  
>>> Thanks!  
>>>
>>  -- 
>> -- 
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines: 
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to nod...@googlegroups.com<javascript:>
>> To unsubscribe from this group, send email to
>> nodejs+un...@googlegroups.com <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>  
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "nodejs" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/nodejs/vuyCAeMFIyE/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> nodejs+un...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to