prevent stupid error on GET w/ data
This commit is contained in:
parent
35f4d87f67
commit
5501d23652
2 changed files with 10 additions and 2 deletions
|
|
@ -908,8 +908,11 @@ Mithril = m = new function app(window, undefined) {
|
|||
if (maybeXhr != null) xhr = maybeXhr
|
||||
}
|
||||
|
||||
if (options.data && (type.call(options.data) != sStr && options.data.constructor != window.FormData)) throw "Request data should be either be a string or FormData. Check the `serialize` option in `m.request`";
|
||||
xhr.send(options.method == "GET" || !options.data ? "" : options.data);
|
||||
var data = options.method == "GET" || !options.data ? "" : options.data
|
||||
if (data && (type.call(data) != sStr && data.constructor != window.FormData)) {
|
||||
throw "Request data should be either be a string or FormData. Check the `serialize` option in `m.request`";
|
||||
}
|
||||
xhr.send(data);
|
||||
return xhr
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1699,6 +1699,11 @@ function testMithril(mock) {
|
|||
mock.XMLHttpRequest.$instances.pop().onreadystatechange()
|
||||
return prop() === "bar"
|
||||
})
|
||||
test(function() {
|
||||
var prop = m.request({method: "GET", url: "test", data: {foo: 1}})
|
||||
mock.XMLHttpRequest.$instances.pop().onreadystatechange()
|
||||
return prop().url === "test?foo=1"
|
||||
})
|
||||
|
||||
// m.request over jsonp
|
||||
test(function(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue