mirror of
https://github.com/zuiidea/antd-admin
synced 2026-11-26 07:44:27 +00:00
switch requst form robe-ajax to axios
This commit is contained in:
+1
-1
@@ -24,7 +24,7 @@ for (let i in mockData) {
|
||||
if (options.url.split('?')[1]) {
|
||||
options.query = serialize(options.url.split('?')[1])
|
||||
} else {
|
||||
options.query = options.body ? serialize(options.body) : {}
|
||||
options.query = options.body ? JSON.parse(options.body) : {}
|
||||
}
|
||||
}
|
||||
let res = {}
|
||||
|
||||
+8
-16
@@ -1,20 +1,12 @@
|
||||
import Ajax from 'robe-ajax'
|
||||
import axios from 'axios'
|
||||
import qs from 'qs'
|
||||
|
||||
export default function request (url, options) {
|
||||
if (options.cross) {
|
||||
return Ajax.getJSON('http://query.yahooapis.com/v1/public/yql', {
|
||||
q: `select * from json where url='${url}?${Ajax.param(options.data)}'`,
|
||||
format: 'json',
|
||||
})
|
||||
export default function request (options) {
|
||||
if (options.url.indexOf('//') > -1 && window.location.origin !== `${options.url.split('//')[0]}//${options.url.split('//')[1].split('/')[0]}`) {
|
||||
options.url = `http://query.yahooapis.com/v1/public/yql?q=select * from json where url='${options.url}?${qs.stringify(options.data)}'&format=json`
|
||||
delete options.data
|
||||
}
|
||||
const { method = 'get' } = options
|
||||
return Ajax.ajax({
|
||||
url,
|
||||
method,
|
||||
data: options.data || {},
|
||||
processData: method === 'get',
|
||||
dataType: 'JSON',
|
||||
}).done((data) => {
|
||||
return data
|
||||
return axios(options).then((result) => {
|
||||
return result.data
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user