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

202
Views
Send data from React Native front end to Express back end

I'm new to React and building a MERN stack. I'm having issues passing a variable from my front end to my back end. I've tried using console logs to debug and I can see that my request body is coming up blank. I've spent hours trying to figure out what I'm doing wrong but I haven't had any breakthrough yet.

Please see my code below.

User Frontend Hook

const fetchUser = (dispatch) => {
  return async () => {
    const email = await AsyncStorage.getItem("email");
    console.log("async email:", email);
    try {
      console.log("sending email:", email);
      const userInfo = await trackerApi.get("/users", {email});
      dispatch({ type: "fetch_users", payload: userInfo.data });
    } catch (err) {
      console.log(err);
    }
  };
};

Express/Axios Backend

router.get("/users", async (req, res) => {
 
     console.log("Request Body:", req.body);
      try {
        const { email } = req.body;
        // console.log("Email for req: ", email);
    
        const user = await User.find({ email: email });
        console.log("Users for req: ", user);
    
        res.send(user);
      } catch (err) {
        console.log(err);
      }
    });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The issue is related to the HTTP method, your route/API is GET call and get method does not have the body, either update to post or use req.query.

Client

const userInfo = await trackerApi.post("/users", {email});
// OR
const userInfo = await trackerApi.post("/users", { data: {email});

Server

router.post("/users", async (req, res) => {
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!