November's Paddleball Marathon
    Have ideas to improve npm?Join in the discussion! »

    angular-xmlrpc

    1.1.1 • Public • Published

    angular-xmlrpc

    An AngularJS service which provides XML-RPC communication methods.

    Installation

    From NPM:

    npm install angular-xmlrpc --save
    

    From Bower:

    bower install angular-xmlrpc
    

    How to use it ?

    First of all, add in you application a dependency :

    angular.module('MyApp', ['xml-rpc']);
    

    This is an AngularJS service, you can use it in your application as any other service.

    angular.module('MyApp')
    .factory('MyAwesomeService', ['xmlrpc', function(xmlrpc){
        return {
            myAwesomeFunction: function(){
                xmlrpc.callMethod(...)
            }
        }
    }]);
    

    In order to pass parameters, you have to wrap them in an array:

    myAwesomeFunction: function(){
        xmlrpc.callMethod('cookies.giveMe', [params1, params2, ...])
    }
    

    Response from the server is automatically parsed from XML to a JS object, you can use it directly:

    xmlrpc.callMethod('user.me', []).then(function(response){
        console.log(response); // { attr1:..., attr2:...}
    })
    

    Configuration

    You can configure the hostName and pathName of your xmlrpc webservice. You can also define a callback for each http error you want:

    angular.module('MyApp.controllers', [])
    .controller('MyAwesomeController', function(xmlrpc) {
        xmlrpc.config({
            hostName:"...", // Default is empty
            pathName:"/...", // Default is /rpc2
            401:function(){
                console.log("You shall not pass !");
            },
            404:function(){
                console.log("Not the droids you're looking for");
            },
            500:function(){
                console.log("Something went wrong :(");
            }, ...
    });
    

    Types

    XML-RPC stardard to JS:

    • base64
    • string
    • int
    • i8
    • i4
    • double
    • boolean
    • struct
    • array
    • datetime
    • datetime.iso8601

    Rock on ! \m/

    Install

    npm i angular-xmlrpc

    DownloadsWeekly Downloads

    1

    Version

    1.1.1

    License

    Apache-2.0

    Last publish

    Collaborators

    • avatar