从 WordPress/WooCommerce 以 Angular 显示 REST API 数据 [英] Displaying REST API data in Angular from WordPress/WooCommerce

查看:62
本文介绍了从 WordPress/WooCommerce 以 Angular 显示 REST API 数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 wordpress/woocomerce 网站,我将使用 Angular 作为主题.我有一个 REST API,我使用 Postman 来测试 API.

我使用 /wp-json/wc/v2/products?g_json 来显示所有产品,但我从 Postman 得到的只是

<代码>{"code": "woocommerce_rest_cannot_view","message": "抱歉,您无法列出资源.",数据": {状态":401}}

我看到有一些认证要做,但我不知道如何使用它.如果我为 API 身份验证添加密钥,我将如何使用此 API 获取数据?

插件链接:- https://github.com/WP-API/Basic-Auth

I am working on a word press/woocomerce website and I will use Angular for the theme. I have a REST API for it, and I was using Postman to test the API.

I have used /wp-json/wc/v2/products?g_json to display all products, but all I get from Postman is

{
    "code": "woocommerce_rest_cannot_view",
    "message": "Sorry, you cannot list resources.",
    "data": {
        "status": 401
    }
}

I saw there is some auth to do, but I don't know how to use it. If I add a key for API auth, how will I be able to get data with this API? https://docs.woocommerce.com/document/woocommerce-rest-api/

I know how to get data from an API, but I have no idea what to do if I am required to send some keys so I can get data from API.

Thanks to anyone who helps me.

解决方案

Used JSON Basic Authentication plugin and used chrome postman addon

Plugin Link:- https://github.com/WP-API/Basic-Auth

这篇关于从 WordPress/WooCommerce 以 Angular 显示 REST API 数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆