按顺序请求接口

需求:有十几个接口,但是必须是按顺序请求这是几个接口

      cityArr:  [
        "110100",
        "110101",
        "110102",
        "110105",
        "110106",
        "110107",
        "110108",
        "110109",
        "110111",
      ], // 城市编码


  methods: {
    /**
     * @Event 方法
     * @description: 获取天气信息
     * */
    async getWeather() {
      this.tableData = []
      for (let i = 0; i < this.cityArr.length; i++) {
        await gaoDeWeather(this.cityArr[i]).then((res) => {
          if (
                  Object.prototype.toString.call(res.data.lives[0]) ===
                  "[object Object]"
          ) {
            this.tableData.push(res.data.lives[0]);
          }
        });
      }
    },
  },

  created() {
    this.getWeather();
  },


// gaoDeWeather 如下

/*               高 德 地 图 获 取 天 气 的 接 口               */
export function gaoDeWeather(city) {
  return request({
    url: "https://urlurlurl,
    method: "get",
    params: {
      key: "key", // 请求服务权限标识
      city: city, // 城市编码
      extensions: null, // 气象类型 可选值:base/all。base:返回实况天气,all:返回预报天气
      output: null, // 返回格式 (可选值:JSON,XML)
    },
  });
}
/*               高 德 地 图 获 取 天 气 的 接 口               */

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值