這是我的目標......這些值來自登錄(它可以是任何東西)-> 對于前電子郵件:'[email protected]' 密碼:'12345678'
我應該使用用戶名直到“@”并將其作為用戶名傳遞給 api。
export const loginUser = (values, history, setFieldError, setSubmitting) => {
console.log("values from login", values)
//here i take the email split value and take as user name
const username = values.email.split("@")[0]
console.log("user name", username)
//now i should pass the username as a name parametr to api
return () => {
axios.get('https://api.agify.io/?', values
).then((response) => {
//if res ok should redirect it
console.log("response", response)
// history.push("/user")
}).catch(error => console.error(error))
setSubmitting(false);
}
}
如果它可以幫助這里是我的鏈接 https://codesandbox.io/s/charming-jang-py0mu?file=/src/auth/actions/userActions.js
uj5u.com熱心網友回復:
我認為這可以完成這項作業(使用模板文字):
axios.get(`https://api.agify.io/?name=${username}`)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/369620.html
標籤:javascript 反应 接口 还原 查询参数
下一篇:有沒有辦法以互動方式除錯反應
