http.js 485 B

1234567891011121314151617
  1. let req = (url, options) => http(url, Object.assign({
  2. async: false
  3. }, options));
  4. function http(url, options = {}) {
  5. if (options?.async === false) return _http(url, options)
  6. return new Promise(resolve => _http(url, Object.assign({
  7. complete: res => resolve(res)
  8. }, options))).catch(err => {
  9. console.error(err.name, err.message, err.stack)
  10. return {
  11. ok: false,
  12. status: 500,
  13. url
  14. }
  15. })
  16. }