Function
xhr
({ url, body = null, method = 'get' })
Source from the content-addressed store, hash-verified
| 1 | import { rootPath, errHandler } from './config' |
| 2 | |
| 3 | const xhr = ({ url, body = null, method = 'get' }) => { |
| 4 | const defer = $.Deferred() |
| 5 | |
| 6 | $.ajax({ |
| 7 | type: method, |
| 8 | url: rootPath + url, |
| 9 | data: body |
| 10 | // xhrFields: { // 跨域允许带上 cookie |
| 11 | // withCredentials: [域名] |
| 12 | // }, |
| 13 | // crossDomain: true |
| 14 | }) |
| 15 | .done(defer.resolve) |
| 16 | .fail(errHandler) |
| 17 | |
| 18 | return defer.promise() |
| 19 | } |
| 20 | |
| 21 | export default xhr |
Tested by
no test coverage detected