Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

268
Views
how to pass parametrs to api?reactjs

here is my target .....the values come from login (it can be anything)-> for ex email:'aaaa@gmail.com' password:'12345678'

i should take username until "@" and pass it to api as a username.

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);
    }
}

if it can help here is my link https://codesandbox.io/s/charming-jang-py0mu?file=/src/auth/actions/userActions.js

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think this can do the job (using template literals) :

axios.get(`https://api.agify.io/?name=${username}`)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!