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

219
Views
Cómo obtener datos en la página html
var axios = require('axios') var data = JSON.stringify({ pair: 'ADA/LCX' }) var config = { method: 'post', url: 'https://exchange-api.lcx.com/order/book', headers: { 'Content-Type': 'application/json', }, data: data, } axios(config) .then(function (response) { console.log(JSON.stringify(response.data)) }) .catch(function (error) { console.log(error) })

quiero insertar este código en la tabla html. cuando ejecuto i en cmd obtengo el resultado, tengo que copiar el archivo siempre en mi escritorio, o no puedo enviar el resultado a html sin copiar el archivo json.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Hizo una pregunta amplia, aquí está la implementación usando React JS y Fetch API, el código puede optimizarse aún más y puede cambiarse de acuerdo con sus necesidades.

Aplicación.js

 import { useEffect, useState } from "react"; import "./styles.css"; export default function App() { const [buy, setBuy] = useState(); const [sell, setSell] = useState(); useEffect(() => { const pairData = { pair: "ADA/LCX" }; fetch("https://exchange-api.lcx.com/order/book", { method: "POST", header: "Content-Type: application/json", body: JSON.stringify(pairData) }).then(function (response) { response.json().then(function (data) { setBuy(data.data.buy); setSell(data.data.sell); }); }); }, [buy]); return ( <> <table className="customers"> <tr> <th>Buy - Start</th> <th>Buy - End</th> </tr> {buy ? Object.entries(buy).map(([make, type]) => { return ( <tr> <td>{type[0]}</td> <td>{type[1]}</td> </tr> ); }) : null} </table> <table className="customers"> <tr> <th>Sell - Start</th> <th>Sell - End</th> </tr> {sell ? Object.entries(sell).map(([make, type]) => { return ( <tr> <td>{type[0]}</td> <td>{type[1]}</td> </tr> ); }) : null} </table> </> ); }

Estilo.css

 .customers { font-family: Arial, Helvetica, sans-serif; border-collapse: collapse; width: 100%; margin-bottom: 20px; text-align: center; } .customers td, #customers th { border: 1px solid #ddd; padding: 8px; } .customers tr:nth-child(even) { background-color: #f2f2f2; } .customers tr:hover { background-color: #ddd; } .customers th { padding-top: 12px; padding-bottom: 12px; background-color: #04aa6d; color: white; }

Demostración en vivo: https://codesandbox.io/s/charming-jennings-ol4vl

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!