Commit f0179a0b authored by 郑磊's avatar 郑磊

更新JSON解析

parent d4dfd31e
...@@ -107,7 +107,7 @@ function request<T = any>( ...@@ -107,7 +107,7 @@ function request<T = any>(
} = options } = options
const xhr = new XMLHttpRequest() const xhr = new XMLHttpRequest()
xhr.responseType = 'json' xhr.responseType = 'text'
xhr.withCredentials = withCredentials xhr.withCredentials = withCredentials
if (typeof timeout === 'number') { if (typeof timeout === 'number') {
xhr.timeout = timeout xhr.timeout = timeout
...@@ -121,7 +121,7 @@ function request<T = any>( ...@@ -121,7 +121,7 @@ function request<T = any>(
resolve({ resolve({
status: xhr.status, status: xhr.status,
headers: parseResponseHeaders(xhr), headers: parseResponseHeaders(xhr),
data: xhr.response, data: JSON.parse(xhr.responseText),
}) })
}) })
xhr.addEventListener('readystatechange', function () { xhr.addEventListener('readystatechange', function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment