vue-resource icon indicating copy to clipboard operation
vue-resource copied to clipboard

What is the definition of bodyText vs body

Open intijk opened this issue 7 years ago • 1 comments

Any documentation describe the difference?

intijk avatar Feb 28 '18 19:02 intijk

Hi! As I understood from source code, bodyText is string representation of response body, and body is parsed text into object: https://github.com/pagekit/vue-resource/blob/61b1efc119ba89a9507ef5c72f1661fcd4db7440/src/http/interceptor/json.js

if (type.indexOf('application/json') === 0 || isJson(text)) {
 try {
    response.body = JSON.parse(text);
} catch (e) {
   response.body = null;
 }
 }
 else {
  response.body = text;
}

In my case in body I get XML content, so it can't be parsed as JSON the body is null, but bodyText is string with XML content.

ankulikov avatar Mar 31 '18 13:03 ankulikov