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

247
Views
Intentando hacer una solicitud POST de axios en el nodo, pero la respuesta del servidor externo muestra que envié una solicitud de datos vacía

Estoy tratando de enviar una solicitud POST pero el servidor al que estoy enviando la solicitud dice que envié un objeto vacío {} , console.log(data) en mi aplicación nodejs y puedo ver que el objeto no está vacío, ¿por qué? ?

 import axios from "axios"; import { readFileSync, createReadStream } from "fs"; import FormData from "form-data"; import dotenv from "dotenv"; dotenv.config(); console.log("Parsing JSON data 💾"); const jsonData = readFileSync("data/data.json").toString(); const products: any[] = JSON.parse(jsonData).products; console.log("Products Store in JavaScript Object 🛒"); products.forEach((product: any, index: number) => { console.log( `Creating Product ${index + 1}/${products.length} - ${product.name}` ); let data = new FormData(); let dataObj: any = {}; for (const [key, value] of Object.entries<string>(product)) { dataObj[key] = value; if (key.includes("image")) { data.append(key, createReadStream(value)); } else { if (key === "variants") { data.append(key, JSON.stringify(value)); } else { data.append(key, value); } } } console.log(data); axios .post("http://localhost:8000/api/v1/product/create", data, { headers: { ...data.getHeaders(), Cookie: `access_token=${process.env.ACCESS_TOKEN}; csrftoken=${process.env.CSRF_TOKEN}`, }, }) .then(() => { console.log(`Product - ${product.name} Created ✔`); }) .catch((err) => { console.log(`Product - ${product.name} Failed to create ❌`); if (err.response) { console.log(err.response.data); } else { console.log("Internal server error"); } }); });
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!