import axios from "axios"
/**
 * http 请求json
 */

export function getHttpJson(url: string): Promise<{ code: number; data: Record<string, any> }> {
  return new Promise((res, rej) => {
    axios
      .get(url)
      .then(resData => {
        if (resData.status === 200 && typeof resData.data === "object") {
          res({
            code: 200,
            data: resData.data
          })
        } else {
          res({
            code: 500,
            data: {}
          })
        }
      })
      .catch(() => {
        res({
          code: 500,
          data: {}
        })
      })
  })
}
