在与woocommerce商店连接时缺少离子3中的参数
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在与woocommerce商店连接时缺少离子3中的参数相关的知识,希望对你有一定的参考价值。
代码是:
signup()
let customerData =
customer :
customerData.customer =
"email": this.newUser.email,
"first_name": this.newUser.first_name,
"last_name": this.newUser.last_name,
"username": this.newUser.username,
"password": this.newUser.password,
"billing_address":
"first_name": this.newUser.first_name,
"last_name": this.newUser.last_name,
"company": "",
"address_1": this.newUser.billing_address.address_1,
"address_2": this.newUser.billing_address.address_2,
"city": this.newUser.billing_address.city,
"state": this.newUser.billing_address.state,
"postcode": this.newUser.billing_address.postcode,
"country": this.newUser.billing_address.country,
"email": this.newUser.email,
"phone": this.newUser.billing_address.phone
,
"shipping_address":
"first_name": this.newUser.first_name,
"last_name": this.newUser.last_name,
"company": "",
"address_1": this.newUser.shipping_address.address_1,
"address_2": this.newUser.shipping_address.address_2,
"city": this.newUser.shipping_address.city,
"state": this.newUser.shipping_address.state,
"postcode": this.newUser.shipping_address.postcode,
"country": this.newUser.shipping_address.country
if(this.billing_shipping_same)
this.newUser.shipping_address = this.newUser.shipping_address;
this.WooCommerce.postAsync('customers',customerData).then( (data) =>
let response = (JSON.parse(data.body));
/ignore the parentheses
运行此代码我收到此错误,我无法修复:
code: "rest_missing_callback_param", message: "Missing parameter(s): email, password",…
code
:
"rest_missing_callback_param"
data
:
status: 400, params: ["email", "password"]
params
:
["email", "password"]
status
:
400
message
:
"Missing parameter(s): email, password"
在数据对象中,正确发送电子邮件和密码:
data: params: email: <email here>, password: <password here>
this.Woocommerce.postAsync('customers',customerData.customer).then((data) =>
console.log (JSON.parse(data.body));
)
问题在于您的托管网站支持的帖子功能。通常托管站点强制执行帖子的安全性,因为有时帖子的主体没有通过。您最好在数字海洋,AWS或GCP下创建自己的托管服务器,并按照以下步骤创建wordpress安装。安装wordpress后,添加woocommerce插件并使用chrome CORS插件启用CORS。
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lamp-on-ubuntu-16-04
抱歉一周英语,但我也面临同样的问题。我在config.ts文件和service.ts文件中进行了更改。
最后,它工作正常
错误:“code”:“rest_missing_callback_param”,“message”:“缺少参数:电子邮件,密码”,“数据”:“status”:400,“params”:[“email”,“password” ]
我改变了config.ts中的标题
headers.append('Content-Type','application / json');
并在service.ts文件中执行一些更改
registerCustomer(customer)var params = customer:customer,email:customer.email,password:customer.password,;返回新的Promise(resolve => this.http.post(this.config.setUrl('POST','/ wp-json / wc / v1 / customers?',false),params,this.config.options).map(res => res.json ())。subscribe(data => this.user = data; resolve(this.user);,err => resolve(err.json())); );
- - 要么 - - -
使用此代码
var options:any = ;
registerCustomer(customer)
var params =
customer: customer,
email: customer.email,
password: customer.password,
;
var headers = new Headers();
headers.append('Content-Type', 'application/json');
this.options.withCredentials = true;
this.options.headers = headers;
return new Promise(resolve =>
this.http.post(this.config.setUrl('POST', '/wp-json/wc/v1/customers?', false), params, this.options).map(res => res.json()).subscribe(data =>
this.user = data;
resolve(this.user);
, err =>
alert("You are already registered with this email id !!");
resolve(err.json())
);
);
以上是关于在与woocommerce商店连接时缺少离子3中的参数的主要内容,如果未能解决你的问题,请参考以下文章
仅在商店中用 woocommerce 中的贝宝结帐替换添加到购物车按钮
从 Woocommerce 商店页面中的特定自定义元数据中过滤产品
php 在登录时将WooCommerce客户重定向到商店页面