![](/img/trans.png)
[英]Axios post not working on React Native but works on PostMan
[英]API works in postman but not with axios in React
這是我的 API 電話:使用 postman它在 postman 中工作正常但是當我嘗試使用 axios時
export const getAccountBalance = (id) => async (dispatch, getState) => {
try {
dispatch({
type: BALANCE_FETCH_REQUEST,
});
const {
userLogin: { userInfo },
} = getState();
const config = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${userInfo.token}`,
},
};
const { data } = await axios.get(`getAccountByAccountNo?accountNo=${id}`,config);
console.log(data);
dispatch({
type: BALANCE_FETCH_SUCCESS,
payload: data,
});
} catch (error) {
dispatch({
type: BALANCE_FETCH_FAIL,
payload:
error.response && error.response.data.message
? error.response.data.message
: error.message,
});
}
};
它完全相同 URL 但它給出 404 not found 404 not found響應
請幫助我,我必須提交這個大學項目!!
謝謝
需要訪問絕對路徑 url
const { data } = await axios.get(`http://localhost:6969/v1/api/getAccountByAccountNo?accountNo
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.