[英]Receiving a 200 status code instead of a 201
我正在向API發送一個簡單的Ajax調用,該API將存儲我發送的電子郵件/網址。
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'); });
當我將此信息提交給api時,我得到的是200狀態代碼,而不是201狀態代碼。
我在這里想念什么?
您是否在后端檢查過發送回的狀態碼確定為200?
即res.status(200).send('stuff')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.