UNPKG

474 BPlain TextView Raw
1import {RESPONSE_TYPE_TEXT} from "../config/responseTypes";
2import {matchType} from "./matcher";
3import {TYPE_OBJECT} from "../config/baseType";
4
5const transferResponseData = (xhr) => {
6 switch (xhr.responseType) {
7 case RESPONSE_TYPE_TEXT:
8 return xhr.response
9 default:
10 return matchType(xhr.response, TYPE_OBJECT)
11 ? xhr.response
12 : JSON.parse(xhr.response)
13 }
14}
15
16export default transferResponseData
\No newline at end of file