第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

axios.get 請求返回 GET,HEAD 作為響應(yīng)

axios.get 請求返回 GET,HEAD 作為響應(yīng)

皈依舞 2022-01-07 13:09:46
我正在使用 React、Redux、Node、Axios 并使用 mongoose-paginate-v2 為我的請求添加分頁。我的 axios.get 看起來像這樣:export const getUsers = (page) => {  return (dispatch, getState) => {    axios.get(`${USERS_ENDPOINT}/${page}`,      {        headers: {          Authorization: `${USERS_TOKEN}`,          "token": cookies.get('token')        }      })      .then(async response => {        dispatch({          type: GET_USERS,          payload: response.data.list,          page: page        });      }).catch(e => { console.log(e); return e })  }}我的 rest-api 函數(shù)如下所示:app.get('/allusers/:page', auth, (req,res)=>{  console.log('req',req)  let log={}  Object.assign(log,{header:req.headers,body:req.body,query:req.query,params:req.params})  request(uri,USERS_FILTER,{token: req.header('token'), page:req.params.page}).then(result => {    res.status(200).send(result);  }).catch(error => {    logger.error('log error',{error:error})    if(error.response.errors[0].message==='Error: 401'){      res.status(401).send('Not Permitted');    }else{      res.status(500).end(); // Or other error handling    }  });  logger.info('users request log',log)});當(dāng)我使用郵遞員對其進(jìn)行測試時,我的后端工作正常,但是當(dāng)我使用我的 UI 發(fā)送請求時,我得到狀態(tài) 200 并GET, HEAD作為響應(yīng),當(dāng)我使用郵遞員時,我得到了一個與我的用戶一起使用的選項卡。這是我的請求的屏幕截圖:PS:我正在使用:節(jié)點 v12.6.0反應(yīng) v16.6.3快遞 v4.16.3
查看完整描述

1 回答

?
qq_花開花謝_0

TA貢獻(xiàn)1835條經(jīng)驗 獲得超7個贊

我使用corshttps://www.npmjs.com/package/cors解決了這個問題 

http://img1.sycdn.imooc.com//61d7cb630001bcc215321020.jpg


查看完整回答
反對 回復(fù) 2022-01-07
  • 1 回答
  • 0 關(guān)注
  • 367 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號