MithrilJS / mithril.js

A JavaScript Framework for Building Brilliant Applications
https://mithril.js.org
MIT License
13.99k stars 926 forks source link

The request extract function should be documented to return "any" and not string. #1723

Closed imanabu closed 7 years ago

imanabu commented 7 years ago

In

[[Mithril Documentation|http://mithril.js.org/request.html]] documents options.extract to be

options.extract string = Function(xhr, options)

This is confusing as what to be returned is a JSON definition and not exactly a string as the example usage suggests,

m.request({
    method: "GET",
    url: "/api/v1/users",
    extract: function(xhr) {return {status: xhr.status, body: xhr.responseText}}
})
.then(function(response) {
    console.log(response.status, response.body)
})

Expected

Change the output to any and not string

options.extract any = Function(xhr, options)

Description Expected

A hook to specify how the XMLHttpRequest response should be read. Useful for reading response headers and cookies. Defaults to a function that returns a JSON object that maps the properties in the xhr and options parameters (e.g. { status: xhr.status }).

dead-claudia commented 7 years ago

Closed per #1729.