Replies: 1 comment 3 replies
-
|
let text = resp.text().await?;
serde_json::from_str(&text).map_err(crate::error::decode)So, you could grab the text, and then |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to fetch some JSON data over http and then deserialize it into a structure, like this:
response::json::<MyStruct>()?. But sometimes the JSON doesn't match my expectations, and the error simply sayserror decoding response body. That's not very helpful. How can I better debug this? Some ideas:dbg!(&response)doesn't work, becauseResponse::fmtdoesn't show the body.dbg!(response.text())doesn't work, becauseResponse::textconsumes theResponseobject, so I can't both print the text and attempt to deserialize it intoMyStruct.dbg!(response.clone().text())doesn't work becauseResponsedoesn't implementClone.So far the best solution I've come up with involves actually fetching the data from the server twice. Is there a better way?
Beta Was this translation helpful? Give feedback.
All reactions