【问题标题】:How to Communicating with an API (curl -X) in Vue?如何在 Vue 中与 API (curl -X) 通信?
【发布时间】:2020-10-04 14:23:05
【问题描述】:

我已将愿望清单项目存储在 cookie 中, 但是在隐身标签中,没有cookie,因此无法获取数据。

我想出了这个扩展的东西,它增加了 3 个端点 https://github.com/mediamanDE/magento-module-wishlist-api

为用户获取愿望清单。

例子:

$ curl -X GET http://magento.example.com/rest/V1/wishlist --header "Authorization: Bearer pbhercbtk6dd3eatf1pyx8jj45avjluu"

如何在 Vue 中发起或调用这个请求?

【问题讨论】:

标签: vue.js vuejs2 vue-component vuetify.js


【解决方案1】:

这应该可以完成工作:

 fetch("http://magento.example.com/rest/V1/wishlist", {
    method: "GET",
    headers: {
      Authorization: "Bearer pbhercbtk6dd3eatf1pyx8jj45avjluu"
    }
  })
    .then(res => res.json())
    .then(response => {
      console.log(response);
    });

【讨论】:

    猜你喜欢
    • 2020-03-30
    • 2021-02-03
    • 2012-04-06
    • 1970-01-01
    • 1970-01-01
    • 2016-01-19
    • 2018-06-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多