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

347
Views
Cómo convertir datos de archivos github sin procesar a JSON

Estoy tratando de convertir datos sin procesar de github a JSON, pero desafortunadamente no puedo hacerlo. Estoy usando reactJs Mi código:

 fetch("https://api.github.com/repos/graphql-compose/graphql-compose-examples/contents/examples/northwind/data/csv/employees.csv") .then((res) => { if (res.ok) { return res.content; // need to convert this content to json } else { throw new Error("Something went wrong"); } }) .then((data) => console.log(data)) .catch((error) => { console.log(error); });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede llamar a json() en la respuesta. Consulte el ejemplo de "solicitud de recuperación básica" aquí .

La propiedad de content contiene un valor codificado en base64, pero también contiene saltos de línea que deben eliminarse antes de poder convertir usando atob . Luego, obtienes líneas CSV:

 fetch("https://api.github.com/repos/graphql-compose/graphql-compose-examples/contents/examples/northwind/data/csv/employees.csv") .then(res => res.json()) .then(data => console.log(atob(data.content.replace('\n', ''))))

Producción:

 employeeID,lastName,firstName,title,titleOfCourtesy,birthDate,hireDate,address,city,region,postalCode,country,homePhone,extension,photo,notes,reportsTo,photoPath 1,Davolio,Nancy,Sales Representative,Ms.,1948-12-08 00:00:00.000,1992-05-01 00:00:00.000,507 20th Ave. E. Apt. 2A,Seattle,WA,98122,USA,(206) 555-9857,5467,0x151C2F00020000000D000E0014002100FFFFFFFF4269746D617020496D616765005061696E742E506963747572650001050000020000000700000050427275736800000000000000000020540000424D20540000000000007600000028000000C0000000DF0000000100040000000000A0530000CE0E0000D80E0000000000,Education includes a BA in psychology from Colorado State University in 1970. She also completed The Art of the Cold Call. Nancy is a member of Toastmasters International.,2,http://accweb/emmployees/davolio.bmp ...
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!