add withCredentials option in m.request
This commit is contained in:
parent
d63cacbe3c
commit
d1c2a44de8
2 changed files with 18 additions and 16 deletions
|
|
@ -20,7 +20,7 @@
|
||||||
`promise = m.request([url,] options)`
|
`promise = m.request([url,] options)`
|
||||||
|
|
||||||
Argument | Type | Required | Description
|
Argument | Type | Required | Description
|
||||||
---------------------- | --------------------------------- | -------- | ---
|
------------------------- | --------------------------------- | -------- | ---
|
||||||
`url` | `String` | No | If present, it's equivalent to having the options `{method: "GET", url: url}`. Values passed to the `options` argument override options set via this shorthand.
|
`url` | `String` | No | If present, it's equivalent to having the options `{method: "GET", url: url}`. Values passed to the `options` argument override options set via this shorthand.
|
||||||
`options.method` | `String` | No | The HTTP method to use. This value should be one of the following: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `HEAD` or `OPTIONS`. Defaults to `GET`.
|
`options.method` | `String` | No | The HTTP method to use. This value should be one of the following: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `HEAD` or `OPTIONS`. Defaults to `GET`.
|
||||||
`options.url` | `String` | Yes | The URL to send the request to. The URL may be either absolute or relative, and it may contain [interpolations](#dynamic-urls).
|
`options.url` | `String` | Yes | The URL to send the request to. The URL may be either absolute or relative, and it may contain [interpolations](#dynamic-urls).
|
||||||
|
|
@ -28,6 +28,7 @@ Argument | Type | Required | Descript
|
||||||
`options.async` | `Boolean` | No | Whether the request should be asynchronous. Defaults to `true`.
|
`options.async` | `Boolean` | No | Whether the request should be asynchronous. Defaults to `true`.
|
||||||
`options.user` | `String` | No | A username for HTTP authorization. Defaults to `undefined`.
|
`options.user` | `String` | No | A username for HTTP authorization. Defaults to `undefined`.
|
||||||
`options.password` | `String` | No | A password for HTTP authorization. Defaults to `undefined`. This option is provided for `XMLHttpRequest` compatibility, but you should avoid using it because it sends the password in plain text over the network.
|
`options.password` | `String` | No | A password for HTTP authorization. Defaults to `undefined`. This option is provided for `XMLHttpRequest` compatibility, but you should avoid using it because it sends the password in plain text over the network.
|
||||||
|
`options.withCredentials` | `Boolean` | No | Whether to send cookies to 3rd party domains. Defaults to `false`
|
||||||
`options.config` | `xhr = Function(xhr)` | No | Exposes the underlying XMLHttpRequest object for low-level configuration. Defaults to the [identity function](https://en.wikipedia.org/wiki/Identity_function).
|
`options.config` | `xhr = Function(xhr)` | No | Exposes the underlying XMLHttpRequest object for low-level configuration. Defaults to the [identity function](https://en.wikipedia.org/wiki/Identity_function).
|
||||||
`options.type` | `any = Function(any)` | No | A constructor to be applied to each object in the response. Defaults to the [identity function](https://en.wikipedia.org/wiki/Identity_function).
|
`options.type` | `any = Function(any)` | No | A constructor to be applied to each object in the response. Defaults to the [identity function](https://en.wikipedia.org/wiki/Identity_function).
|
||||||
`options.serialize` | `string = Function(any)` | No | A serialization method to be applied to `data`. Defaults to `JSON.stringify`, or if `options.data` is an instance of [`FormData`](https://developer.mozilla.org/en/docs/Web/API/FormData), defaults to the [identity function](https://en.wikipedia.org/wiki/Identity_function) (i.e. `function(value) {return value}`).
|
`options.serialize` | `string = Function(any)` | No | A serialization method to be applied to `data`. Defaults to `JSON.stringify`, or if `options.data` is an instance of [`FormData`](https://developer.mozilla.org/en/docs/Web/API/FormData), defaults to the [identity function](https://en.wikipedia.org/wiki/Identity_function) (i.e. `function(value) {return value}`).
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ module.exports = function($window, Promise) {
|
||||||
if (args.deserialize === deserialize) {
|
if (args.deserialize === deserialize) {
|
||||||
xhr.setRequestHeader("Accept", "application/json, text/*")
|
xhr.setRequestHeader("Accept", "application/json, text/*")
|
||||||
}
|
}
|
||||||
|
if (args.withCredentials) xhr.withCredentials = args.withCredentials
|
||||||
|
|
||||||
if (typeof args.config === "function") xhr = args.config(xhr, args) || xhr
|
if (typeof args.config === "function") xhr = args.config(xhr, args) || xhr
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue