我正在使用飞轮本地的wordpress网站(url:xyz.Local(。我创建了一个新的盖茨比网站使用并添加了盖茨比源wooccommerce。我还从woo商业设置中生成了消费者密钥和消费者秘密。我将它们添加到配置文件中的apikeys中。
当我运行gastby-develop时,我得到了这个错误。
========== WARNING FOR FIELD products ===========
The following error status was produced: Error: connect ECONNREFUSED 127.0.0.1:8080
================== END WARNING ==================
08:19:23.204Z > gatsby-source-woocommerce: Fetching 0 nodes for field: products
08:19:23.206Z > gatsby-source-woocommerce: Completed fetching nodes for field: products
warn
========== WARNING FOR FIELD products/categories ===========
The following error status was produced: Error: connect ECONNREFUSED 127.0.0.1:8080
================== END WARNING ==================
08:19:23.213Z > gatsby-source-woocommerce: Fetching 0 nodes for field: products/categories
08:19:23.215Z > gatsby-source-woocommerce: Completed fetching nodes for field: products/categories
warn
========== WARNING FOR FIELD products/attributes ===========
The following error status was produced: Error: connect ECONNREFUSED 127.0.0.1:8080
================== END WARNING ==================
有人能告诉我是否遗漏了什么吗?或者我做错了什么?
我解决了它。问题出在插件上。在gatsby-source wooccommerce的配置选项中,评论字段后的所有内容,即评论后看起来像,
{
resolve: "@pasdo501/gatsby-source-woocommerce",
options: {
// Base URL of Wordpress site
api: "wordpress.domain",
// set to false to not see verbose output during build
// default: true
verbose: true,
// true if using https. otherwise false.
https: false,
api_keys: {
consumer_key: <key>,
consumer_secret: <secret>,
},
// Array of strings with fields you'd like to create nodes for...
fields: ["products", "products/categories", "products/attributes"],
},
},
前往@pado501/gatsby源wooccommerce文件夹(节点模块(->gatsby-node.jschange api_version=";wc/v3";至";wc/v2";和将wpAPIPrefix=null更改为"空";wp-json";并保存。
voila
无需更改包。你可以这样做:
-
将
/index.php
添加到api
的末尾。 -
将CCD_ 3设置为CCD_。
-
将
query_string_auth
设置为true
(我不确定是否需要这个(。{ resolve: '@pasdo501/gatsby-source-woocommerce', options: { api: 'pro.com/index.php', https: true, verbose: true, api_keys: { consumer_key: `ck_...........`, consumer_secret: `cs_.................`, }, fields: ['products', 'products/categories', 'products/attributes', 'products/tags'], wpAPIPrefix: 'wp-json', query_string_auth: true, api_version: 'wc/v3', // per_page: 100, // encoding: 'utf8', // axios_config: {} } }