0
雖然使用下面的代碼,我得到
400錯誤的請求rest_missing_callback_params
$scope.signUp = function() {
var data = {
\t email: $scope.email,
\t password: $scope.password,
\t first_name: $scope.fName,
\t last_name: $scope.lName,
\t username: $scope.uName,
\t billing: {
\t \t first_name: $scope.fName,
\t \t last_name: $scope.lName,
\t \t company: $scope.cName,
\t \t address_1: $scope.address1,
\t \t address_2: $scope.address2,
\t \t city: $scope.city,
\t \t state: $scope.state,
\t \t postcode: $scope.pcode,
\t \t country: $scope.country,
\t \t email: $scope.email,
\t \t phone: $scope.mobile,
\t },
\t shipping: {
\t \t first_name: $scope.fName1,
\t \t last_name: $scope.lName1,
\t \t company: $scope.cName1,
\t \t address_1: $scope.address11,
\t \t address_2: $scope.address12,
\t \t city: $scope.city1,
\t \t state: $scope.state1,
\t \t postcode: $scope.pcode1,
\t \t country: $scope.country1,
\t }
}
console.log(data)
$http.post("https://www.colourssoftware.com/wordpress/wp-json/wc/v1/customers", {
\t \t headers: {
\t \t \t 'Content-Type': 'application/json',
\t \t \t 'Authorization': 'Basic ' + window.btoa("username:password")
\t \t },
\t \t data: data
\t })
\t .then(function (response) {
\t \t console.log(response)
\t }, function (response) {
\t \t console.log(response);
\t });
}
但是當我用下面的代碼,它將數據發佈到服務器。
var au = window.btoa("username:password"),
req = {
\t method: 'POST',
\t url: 'https://www.colourssoftware.com/wordpress/wp-json/wc/v1/customers',
\t headers: {
\t \t 'Content-Type': 'application/json',
\t \t 'Authorization': 'Basic ' + au
\t },
\t data: data
}
$http(req).then(function (response) {
\t console.log(response)
}, function (response) {
\t console.log(response);
});
的是這兩者之間的區別?爲什麼會發生這種情況?
檢查開發者工具的網絡標籤...看到什麼是在每個請求發送,如果你看出其中的區別,你有你的答案 –
儘管IAM發送電子郵件和密碼,它提供了錯誤丟失的電子郵件和密碼 –
等等,請求頭或帖子參數完全沒有區別? –