Improve this Doc View Source $httpProvider

  1. $http
  2. provider in module ng

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

Methods

  • 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.

    Parameters

    Param Type Details
    value
    (optional)
    boolean

    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.

    Returns

    booleanObject

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

  • useLegacyPromiseExtensions([value]);

    Deprecated: (since v1.4.4) (to be removed in v1.6.0)

    This method will be removed in v1.6.0 along with the legacy promise methods.

    Configure $http service to return promises without the shorthand methods success and error. This should be used to make sure that applications work without these methods.

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

    Parameters

    Param Type Details
    value
    (optional)
    boolean

    If true, $http will return a promise with the deprecated legacy success and error methods.

    Returns

    booleanObject

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

Properties

  • 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.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'.

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

      • defaults.headers.common
      • defaults.headers.post
      • defaults.headers.put
      • defaults.headers.patch
    • 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.
  • 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

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://code.angularjs.org/1.5.11/docs/api/ng/provider/$httpProvider