From c075ac7b4989ee79f50db9f739c7be3e36ce10c1 Mon Sep 17 00:00:00 2001 From: Gabriel Aumala Date: Wed, 22 Aug 2018 00:40:50 -0500 Subject: [PATCH] docs: improve m.request return value description In the m.request return value description, add a line informing that error status codes cause the promise to reject. --- docs/request.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/request.md b/docs/request.md index 3fe2fb99..6cd03b07 100644 --- a/docs/request.md +++ b/docs/request.md @@ -61,7 +61,7 @@ Argument | Type | Required | Descr `options.deserialize` | `any = Function(any)` | No | A deserialization method to be applied to the `xhr.response` or normalized `xhr.responseText`. Defaults to the [identity function](https://en.wikipedia.org/wiki/Identity_function). If `extract` is defined, `deserialize` will be skipped. `options.extract` | `any = Function(xhr, options)` | No | A hook to specify how the XMLHttpRequest response should be read. Useful for processing response data, reading headers and cookies. By default this is a function that returns `options.deserialize(parsedResponse)`, throwing an exception when the server response status code indicates an error or when the response is syntactically invalid. If a custom `extract` callback is provided, the `xhr` parameter is the XMLHttpRequest instance used for the request, and `options` is the object that was passed to the `m.request` call. Additionally, `deserialize` will be skipped and the value returned from the extract callback will be left as-is when the promise resolves. `options.background` | `Boolean` | No | If `false`, redraws mounted components upon completion of the request. If `true`, it does not. Defaults to `false`. -**returns** | `Promise` | | A promise that resolves to the response data, after it has been piped through the `extract`, `deserialize` and `type` methods +**returns** | `Promise` | | A promise that resolves to the response data, after it has been piped through the `extract`, `deserialize` and `type` methods. If the response status code indicates an error, the promise rejects, but this can be prevented by setting the `extract` option. `promise = m.request(url, options)`