add example for m.request config
This commit is contained in:
parent
b2daa1b55a
commit
3f8c630702
3 changed files with 22 additions and 0 deletions
|
|
@ -226,6 +226,20 @@ var file = m.request({
|
|||
});
|
||||
```
|
||||
|
||||
### Configuring the underlying XMLHttpRequest
|
||||
|
||||
The `config` option can be used to arbitrarily configure the native XMLHttpRequest instance and to access properties that would not be accessible otherwise.
|
||||
|
||||
The example below show how to configure a request where the server expects requests to have a `Content-Type: application/json` header
|
||||
|
||||
```javascript
|
||||
var xhrConfig = function(xhr) {
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
}
|
||||
|
||||
m.request({method: "POST", url: "/foo", config: xhrConfig});
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Signature
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue