mardi 29 novembre 2016

Is there any way to set the custom header when making a API call?

I want to add custom header at the time of API call. I am actually calling a function from controller and inside that function the $resource object is going to be set as follows:

// Generate the $resource object based on the stored API object
                    var resourceObject = $resource(apiObject.url, apiObject.paramDefaults, apiObject.actions, apiObject.options);

                    // Make the call...
                    resourceObject[method](params,

                        // Success
                        function (response)
                        {
                            deferred.resolve(response);

                            // Emit an event
                            $rootScope.$broadcast('msApi::resolveSuccess');
                        },

                        // Error
                        function (response)
                        {
                            deferred.reject(response);

                            // Emit an event
                            $rootScope.$broadcast('msApi::resolveError');
                        }
                    );

How to add custom header inside this ?




Aucun commentaire:

Enregistrer un commentaire