Nuxt JS检查端点存在

时间:2019-07-09 08:12:09

标签: javascript vue.js nuxt

如何检查nuxt js中是否存在端点?例如,此URL:https://www.google.com/favicon.ico

async asyncData({ app, params, env, error, store }) {
      var _icon = "https://www.google.com/favicon.ico";
      try {
         var result = await app.$axios(_icon);
      } catch (error) {
        console.log(error)
      }

}


  [1]: https://i.stack.imgur.com/7RT5K.png

1 个答案:

答案 0 :(得分:0)

使用“ $ axios”时,您会忘记“ $ get”

async asyncData({ app, params, env, error, store }) {
      var _icon = "https://www.google.com/favicon.ico";
      try {
         var result = await app.$axios.$get(_icon);
      } catch (error) {
        console.log(error)
      }

}