首页 > 解决方案 > JSON中位置0处的意外令牌<。获取函数VueJS

问题描述

伙计们,我在使用这个 fetch 功能时遇到了麻烦

fetchWeather() {
    fetch(`${this.url_base}weather?q=${this.query}&units=metric&APPID=${this.api_key}`)
    .then(res => {
      return res.json()
    }).then(this.setResults)
  },
  setResults(results) {
    this.weather = results
  },

它说“Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0”

我做错了什么?

标签: javascriptjsonfunctionvue.jsfetch

解决方案


推荐阅读