http service

loading...

Result
{{key}} {{value}}
httpService.Weather(model).then(function (weather) {
    // do something with result
}).catch(function (error) {
    // handle error
});

httpService.User.Save(model).then(function (result) {
    // do something with result
}).catch(function (error) {
    // handle error
});
httpService.actionName(model);
name type arguments notes
could be anything function model=[object] returns a promise object

Other kama angularjs modules use this module in various places. So although this service in empty by default, its existence is required.

This service is inherited from AngularJS $http service. So every action should return a promise object. It's recommended that you put all of your http calls in httpService and then access it from httpService whenever you want to send a http request.

You can expand http service in your application by creating another service like this:

(function () {
    angular
        .module('yourModule')
        .run(run)
        .factory('customHttpService', customHttpService);

    run.$inject = ['customHttpService'];
    funcrion run(customHttpService) { }

    customHttpService.$inject = ['httpService', '$http', '$q'];
    function customHttpService(httpService, $http, $q) {
        httpService.PrayerTime = {};
        httpService.PrayerTime.ByCity = function (model) {
            return $http({
                method: 'POST'
                , url: 'https://prayer.aviny.com/api/prayertimes/'
                , data: model
            }).then(function (result) {
                if (result.status != 200)
                    return $q.reject('خطای ناشناخته')

                return result.data;
            }).catch(function (error) {
                return $q.reject(error);
            });
        }

        return httpService;
    }
})();