带有Axios的VUE需要5到7秒的API调用,并带有小数据

发布于 2025-01-31 11:06:37 字数 1504 浏览 0 评论 0 原文

美好的一天,

我的VUE应用程序有很大的问题,即我的API电话非常慢。

我有一个Laravel的后端,可以及时提供数据,该数据通过域

但是,在我的仪表板中,我在其中拨打了三个API调用,它需要5到8秒钟才能加载内容:

因此,用户大量抱怨加载时间。 在代码中,我目前将呼叫调用如下:

  async mounted() {
    this.personalDeletegatesId = userInfo.user.delegatesid
    this.getTasks()
    this.getAddresses()
    this.getRequestTypes()
  },

每个函数都是作为异步方法创建的。 应用程序中的应用程序既不快。

    getAddresses: async function () {
      this.$http.get('/addresses/delegates/' + userInfo.user.delegatesid)
          .then(function (response) {
            this.items = uniqueElementsBy(response.data[0], (a, b) => a.id == b.id)
            this.itemsnotasks = uniqueElementsBy(response.data[1], (a, b) => a.id == b.id)
            this.itemsfav = uniqueElementsBy(response.data[2], (a, b) => a.id == b.id)
            this.getCounts()

            }.bind(this))
    },
    getTasks: async function () {
      this.$http.get('/salestasks/delegates/' + userInfo.user.delegatesid)
          .then(function (response) {
            this.itemsTasks = uniqueElementsBy(response.data, (a, b) => a.salestasks_id == b.salestasks_id)
          }.bind(this))
    },

Good day,

I have quite a problem with my VUE application, namely my API calls are very very slow.

I have a Laravel backend that provides the data in a timely manner, which responds accordingly via a domain https://api.example.com.

However, with my dashboard, where I make three API calls, it takes me between 5 and 8 seconds for the content to load:
enter image description here

As a result, users complain massively about the loading times.
In the code, I currently call the calls as follows:

  async mounted() {
    this.personalDeletegatesId = userInfo.user.delegatesid
    this.getTasks()
    this.getAddresses()
    this.getRequestTypes()
  },

The functions were each created as an async method.
Neither in production nor in local is the application fast.

    getAddresses: async function () {
      this.$http.get('/addresses/delegates/' + userInfo.user.delegatesid)
          .then(function (response) {
            this.items = uniqueElementsBy(response.data[0], (a, b) => a.id == b.id)
            this.itemsnotasks = uniqueElementsBy(response.data[1], (a, b) => a.id == b.id)
            this.itemsfav = uniqueElementsBy(response.data[2], (a, b) => a.id == b.id)
            this.getCounts()

            }.bind(this))
    },
    getTasks: async function () {
      this.$http.get('/salestasks/delegates/' + userInfo.user.delegatesid)
          .then(function (response) {
            this.itemsTasks = uniqueElementsBy(response.data, (a, b) => a.salestasks_id == b.salestasks_id)
          }.bind(this))
    },

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文