make xhr.abort reject promise chain
This commit is contained in:
parent
c1f6705a59
commit
38dba03f6d
11 changed files with 69 additions and 13 deletions
|
|
@ -233,6 +233,15 @@ m.request({method: "POST", url: "/foo", extract: extract});<
|
|||
|
||||
m.request({method: "POST", url: "/foo", config: xhrConfig});</code></pre>
|
||||
<hr>
|
||||
<h3 id="aborting-a-request">Aborting a request</h3>
|
||||
<p>The <code>config</code> option can also be used to retrieve the <code>XMLHttpRequest</code> instance for aborting the request. This idiom can also be used to attach <code>onprogress</code> event handlers.</p>
|
||||
<pre><code class="lang-javascript">var transport = m.prop();
|
||||
|
||||
m.request({method: "POST", url: "/foo", config: transport});
|
||||
|
||||
//the `transport` getter-setter contains an instance of XMLHttpRequest
|
||||
transport().abort();</code></pre>
|
||||
<hr>
|
||||
<h3 id="signature">Signature</h3>
|
||||
<p><a href="how-to-read-signatures.html">How to read signatures</a></p>
|
||||
<pre><code class="lang-clike">Promise request(XHROptions options)
|
||||
|
|
@ -277,7 +286,7 @@ where:
|
|||
<p>Data to be sent. It's automatically placed in the appropriate section of the request with the appropriate serialization based on <code>method</code></p>
|
||||
</li>
|
||||
<li><p><strong>any unwrapSuccess(any data)</strong> (optional)</p>
|
||||
<p>A preprocessor function to extract the data from a success response in case the response contains metadata wrapping the data.</p>
|
||||
<p>A preprocessor function to unwrap the data from a success response in case the response contains metadata wrapping the data.</p>
|
||||
<p>The default value (if this parameter is falsy) is the identity function <code>function(value) {return value}</code></p>
|
||||
<p>For example, if the response is <code>{data: [{name: "John"}, {name: "Mary"}]}</code> and the unwrap function is <code>function(response) {return response.data}</code>, then the response will be considered to be <code>[{name: "John"}, {name: "Mary"}]</code> when processing the <code>type</code> parameter</p>
|
||||
<ul>
|
||||
|
|
@ -290,7 +299,7 @@ where:
|
|||
</ul>
|
||||
</li>
|
||||
<li><p><strong>any unwrapError(any data)</strong> (optional)</p>
|
||||
<p>A preprocessor function to extract the data from an error response in case the response contains metadata wrapping the data.</p>
|
||||
<p>A preprocessor function to unwrap the data from an error response in case the response contains metadata wrapping the data.</p>
|
||||
<p>The default value (if this parameter is falsy) is the identity function <code>function(value) {return value}</code></p>
|
||||
<ul>
|
||||
<li><p><strong>Object<any> | Array<any> data</strong></p>
|
||||
|
|
@ -325,7 +334,7 @@ where:
|
|||
</li>
|
||||
<li><p><strong>any extract(XMLHttpRequest xhr, XHROptions options)</strong> (optional)</p>
|
||||
<p>Method to use to extract the data from the raw XMLHttpRequest. This is useful when the relevant data is either in a response header or the status field.</p>
|
||||
<p>If this parameter is falsy, the default value is <code>function(xhr, options) {return xhr.responseText}</code>.</p>
|
||||
<p>If this parameter is falsy, the default value is a function that returns <code>xhr.responseText</code>.</p>
|
||||
</li>
|
||||
<li><p><strong>void type(Object<any> data)</strong> (optional)</p>
|
||||
<p>The response object (or the child items if this object is an Array) will be passed as a parameter to the class constructor defined by <code>type</code></p>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue