* Fix for #2423. request.data is replaced by body, params is used for querystring interpolation. * Updated documentation after code review by shadowhand and isiahmeadows * Convert indentation to tabs * Replacing m.request.data and m.jsonp.data with params or body. * Update request.md Co-authored-by: Isiah Meadows <contact@isiahmeadows.com>
This commit is contained in:
parent
e82f6d00c2
commit
8a7eae00ed
7 changed files with 40 additions and 40 deletions
|
|
@ -255,7 +255,7 @@ Basically, XHR is just a way to talk to a server.
|
|||
|
||||
Let's change our click counter to make it save data on a server. For the server, we'll use [REM](http://rem-rest-api.herokuapp.com), a mock REST API designed for toy apps like this tutorial.
|
||||
|
||||
First we create a function that calls `m.request`. The `url` specifies an endpoint that represents a resource, the `method` specifies the type of action we're taking (typically the `PUT` method [upserts](https://en.wiktionary.org/wiki/upsert)), `data` is the payload that we're sending to the endpoint and `withCredentials` means to enable cookies (a requirement for the REM API to work)
|
||||
First we create a function that calls `m.request`. The `url` specifies an endpoint that represents a resource, the `method` specifies the type of action we're taking (typically the `PUT` method [upserts](https://en.wiktionary.org/wiki/upsert)), `body` is the payload that we're sending to the endpoint and `withCredentials` means to enable cookies (a requirement for the REM API to work)
|
||||
|
||||
```javascript
|
||||
var count = 0
|
||||
|
|
@ -263,7 +263,7 @@ var increment = function() {
|
|||
m.request({
|
||||
method: "PUT",
|
||||
url: "//rem-rest-api.herokuapp.com/api/tutorial/1",
|
||||
data: {count: count + 1},
|
||||
body: {count: count + 1},
|
||||
withCredentials: true,
|
||||
})
|
||||
.then(function(data) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue