* 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
|
|
@ -14,7 +14,7 @@ Makes JSON-P requests. Typically, it's useful to interact with servers that allo
|
|||
```javascript
|
||||
m.jsonp({
|
||||
url: "/api/v1/users/:id",
|
||||
data: {id: 1},
|
||||
params: {id: 1},
|
||||
callbackKey: "callback",
|
||||
})
|
||||
.then(function(result) {
|
||||
|
|
@ -31,8 +31,8 @@ m.jsonp({
|
|||
Argument | Type | Required | Description
|
||||
---------------------- | --------------------------------- | -------- | ---
|
||||
`options` | `Object` | Yes | The request options to pass.
|
||||
`options.url` | `String` | Yes | The [path name](paths.md) to send the request to, optionally interpolated with values from `options.data`.
|
||||
`options.data` | `any` | No | The data to be interpolated into the URL and serialized into the querystring.
|
||||
`options.url` | `String` | Yes | The [path name](paths.md) to send the request to, optionally interpolated with values from `options.params`.
|
||||
`options.params` | `Object` | No | The data to be interpolated into the URL and serialized into the querystring.
|
||||
`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.callbackName` | `String` | No | The name of the function that will be called as the callback. Defaults to a randomized string (e.g. `_mithril_6888197422121285_0({a: 1})`
|
||||
`options.callbackKey` | `String` | No | The name of the querystring parameter name that specifies the callback name. Defaults to `callback` (e.g. `/someapi?callback=_mithril_6888197422121285_0`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue