Improve this Doc View Source $httpProvider

From Get docs
< Provider components in ngAngularjs/docs/1.8/api/ng/provider/$httpprovider

Improve this Doc View Source $httpProvider

  1. $http
  2. provider in module ng


Use $httpProvider to change the default behavior of the $http service.


  • === useApplyAsync([value]); ===

    Configure $http service to combine processing of multiple http responses received at around the same time via $rootScope.$applyAsync. This can result in significant performance improvement for bigger applications that make many HTTP requests concurrently (common during application bootstrap).

    Defaults to false. If no value is specified, returns the current configured value.


    Param Type Details




    If true, when requests are loaded, they will schedule a deferred "apply" on the next tick, giving time for subsequent requests in a roughly ~10ms window to load and share the same digest cycle.



    If a value is specified, returns the $httpProvider for chaining. otherwise, returns the current configured value.


  • === defaults ===

    Object containing default values for all $http requests.

    • defaults.cache - {boolean|Object} - A boolean value or object created with $cacheFactory to enable or disable caching of HTTP responses by default. See $http Caching for more information.

    • defaults.headers - {Object} - Default headers for all $http requests. Refer to $http for documentation on setting default headers.

      • defaults.headers.common
      • defaults.headers.put
      • defaults.headers.patch
    • defaults.jsonpCallbackParam - {string} - the name of the query parameter that passes the name of the callback in a JSONP request. The value of this parameter will be replaced with the expression generated by the $jsonpCallbacks service. Defaults to 'callback'.

    • defaults.paramSerializer - {string|function(Object<string,string>):string} - A function used to the prepare string representation of request parameters (specified as an object). If specified as string, it is interpreted as a function registered with the $injector. Defaults to $httpParamSerializer.

    • defaults.transformRequest - {Array<function(data, headersGetter)>|function(data, headersGetter)} - An array of functions (or a single function) which are applied to the request data. By default, this is an array with one request transformation function:

      • If the data property of the request configuration object contains an object, serialize it into JSON format.
    • defaults.transformResponse - {Array<function(data, headersGetter, status)>|function(data, headersGetter, status)} - An array of functions (or a single function) which are applied to the response data. By default, this is an array which applies one response transformation function that does two things:

    • defaults.xsrfCookieName - {string} - Name of cookie containing the XSRF token. Defaults value is 'XSRF-TOKEN'.

    • defaults.xsrfHeaderName - {string} - Name of HTTP header to populate with the XSRF token. Defaults value is 'X-XSRF-TOKEN'.

  • === interceptors ===

    Array containing service factories for all synchronous or asynchronous $http pre-processing of request or postprocessing of responses.

    These service factories are ordered by request, i.e. they are applied in the same order as the array, on request, but reverse order, on response.

    Interceptors detailed info

  • === xsrfTrustedOrigins ===

    Array containing URLs whose origins are trusted to receive the XSRF token. See the Security Considerations sections for more details on XSRF.

    Note: An "origin" consists of the URI scheme, the hostname and the port number. For http: and https:, the port number can be omitted if using th default ports (80 and 443 respectively). Examples:,

    It is not possible to trust specific URLs/paths. The path, query and fragment parts of a URL will be ignored. For example, will be treated as, meaning that all requests to URLs starting with will include the XSRF token.

  • === xsrfWhitelistedOrigins ===

    Deprecated: (since 1.8.1)

    This property is deprecated. Use xsrfTrustedOrigins instead.

© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 3.0.$httpProvider