1 | import {RESPONSE_TYPE_TEXT} from "../config/responseTypes";
|
2 | import {matchType} from "./matcher";
|
3 | import {TYPE_OBJECT} from "../config/baseType";
|
4 |
|
5 | const 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 |
|
16 | export default transferResponseData |
\ | No newline at end of file |