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

232
Views
Can't pass JSON object with form-data in react js (Always json JSON is an empty)

I need to send a form-data request to my back-end and I need to pass JSON object with my form-data request. But when I send my request to the back-end, my JSON object has no value.

This is my JSON Object.

enter image description here

And This is my React Code:-

export function* addCategoryFlow(action) {
    // JSON Data
    const locals = action.data.displayNameLocalization;

    try {
        const paginationDetails = yield select((state) => state.categoryReducer.pagination);
        const Axios = yield createRequest();
        const formData = new FormData();

        formData.append('displayName', action.data.displayName);
         
        //Convert my Json Data
        formData.append('displayNameLocalization', JSON.stringify(locals));
      

        // CONSOLE LOG MY FORMDATA REQUEST
        for (const pair of formData.entries()) {
            console.log(pair[0] + ', ' + pair[1]);
        }
        const res = yield Axios.post('cms/categories', formData);

        if (res.status === 201) {
            toast.success('Category Added Successful');
            yield put({type: ADD_CATEGORY_SUCCESS});
            yield put({type: GET_CATEGORIES, data: paginationDetails});
        }
    } catch (error) {
        console.log(error);
        toast.error('Category  Added Field');
    }
}

But when I console log my form data (before sending data to the back-end) My JSON data is empty. enter image description here

I don't know the reason. If anyone can help me with this question, It's really helping me to my study as a beginner...Thank you all...❤️

about 4 years ago · Juan Pablo Isaza
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!