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

86
Views
Cómo descomponer la matriz en la solicitud POST

Estoy tratando de hacer una solicitud POST a un servidor API y estoy enviando una matriz de JSON, el problema es que me sale este error:

 cannot unmarshal array into Go value of type models.UserRequest

Traté de desarmarlo usando una fábrica y luego inicializando los objetos, pero sigo recibiendo este error, ¿cómo puedo solucionar este error y hacer mi solicitud? Aquí está mi código:

 import fetch from 'node-fetch'; import xlsx from 'xlsx'; const baseUrl = ""; const apiToken = ""; const accountId = ""; const wb = xlsx.readFile('users.xlsx'); const ws = wb.Sheets['users']; const data = xlsx.utils.sheet_to_json(ws); // console.log(data) const options = { method: "POST", headers: { Authorization: `Bearer ${apiToken}`, "gtmhub-accountid": accountId, "Content-type": "application/json; charset=UTF-8", Accept: "application/json, text/plain, */*", }, body: JSON.stringify( data ), }; const createUser = (url, settings) => { return fetch(`${url}/users`, settings) .then((response) => response.text()) .then((data) => console.log(data)) .catch((error) => { console.log(error.message); }); }; createUser(baseUrl, options);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debería poder enviar la estructura de objeto correcta a su servicio API. También esto parece ser el problema en el lado del servicio api

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!