Function xFetch

  • fetch 简单封装

    Parameters

    • method: string

      Http Method

    • url: string

      地址/链接

    • Optionaloptions: {
          callback?: any;
          data?: any;
          headers?: any;
          isFile?: boolean;
          params?: any;
          raw?: boolean;
      }

      请求配置

      • Optionalcallback?: any
      • Optionaldata?: any
      • Optionalheaders?: any
      • OptionalisFile?: boolean
      • Optionalparams?: any
      • Optionalraw?: boolean

    Returns Promise<any>

    xFetch('get', 'https://api.uomg.com/api/rand.qinghua?x=1', { params: { format: 'json', hello: 456 } }).then(data => console.log(data)); /// fetchXPromise
    xFetch('POST', 'https://test.cn', { headers: { contentType: 'application/json' }, data: { test: 123 } }).catch(error => console.log(error)); /// fetchXPromise