We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 802d5d5 commit d7c667eCopy full SHA for d7c667e
src/browser/fetch/response.rs
@@ -14,6 +14,9 @@ pub struct Response {
14
15
impl Response {
16
/// Get a `String` from response body.
17
+ ///
18
+ /// # Errors
19
+ /// Returns `FetchError::PromiseError`.
20
pub async fn text(self) -> Result<String> {
21
let js_promise = self.raw_response.text().map_err(FetchError::PromiseError)?;
22
@@ -27,6 +30,9 @@ impl Response {
27
30
}
28
31
29
32
/// JSON parse response body into provided type.
33
34
35
+ /// Returns `FetchError::SerdeError` or `FetchError::PromiseError`.
36
pub async fn json<T: DeserializeOwned + 'static>(self) -> Result<T> {
37
let text = self.text().await?;
38
serde_json::from_str(&text).map_err(FetchError::SerdeError)
0 commit comments