0
我正在向api發送一個簡單的ajax調用,以存儲我發送的電子郵件/網址。接收200狀態代碼而不是201
const emailAnswer = this.state.emailAnswer;
const emailText = `${emailAnswer}`;
const fullurl = window.location.href;
const fullurlText = `${fullurl}`;
console.log(fullurlText);
$.ajax({
url: '/email',
method: 'POST',
data: {
email: emailText,
url: fullurlText
},
statusCode: {
200: function() {
console.log('you got a 200');
},
201: function() {
console.log('saved');
},
400: function() {
console.log('email not posted');
}
},
}).done(function() {
console.log('done');
});
我得到一個200個狀態碼回來時,我提交該信息的API,而不是201個狀態碼。
我在這裏錯過了什麼?
檢查後端。 200對我們的目的應該沒問題。 –