function ajax()

in shadingsphere-benchmark-ui/src/utils/api.js [53:90]


function ajax(url, type, options) {
  return new Promise((resolve, reject) => {
    axios({
      method: type,
      url: HOST + url + TAIL,
      timeout: 3000,
      responseType: 'json'
    })
      .then(
        result => {
          const { data, status } = result
          if (status === 200) {
            resolve(data)
          }
        },
        error => {
          const { message } = error
          if (message.includes('timeout')) {
            Notice.info({
              title: 'Prompt information',
              desc: 'please try again later!'
            })
          }
          reject(error)
        }
      )
      .catch((error) => {
        Notice.error({
          title: 'Prompt information',
          description: error
        })
        reject({
          error: true,
          msg: error
        })
      })
  })
}