无法使用 axios 从服务器获取数据获取响应

问题描述

我正在尝试使用 axios get 响应从服务器获取 json 数据。

<script>
  import axios from 'axios';

  export default {
    data() {
      return {
        films: [],};
    },methods: {
      getFilms() {
        const path = 'http://localhost:5000/api/v1.0/films';
        axios.get(path)
          .then((res) => {
            this.films = res.data.films;
          })
          .catch((error) => {
            console.error(error);
          });
      },},created() {
      this.getFilms();
    },};
</script>

但结果我有空列表。我怎样才能解决这个问题?或者 mb 还有另一种从服务器获取数据的方法

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)