Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

223
Visualizações
How to get data into html page
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)
  })

i want to insert this code into html table. when i run i on cmd is get result, i have to copy file alwys on my desktop, or i cant send the result into html whitout copy of json file?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You asked a wide question, here is the implementation of it using React JS and Fetch API, the code maybe optimized further and can be change according to your needs.

App.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>
    </>
  );
}

Style.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;
}

Live Demo: https://codesandbox.io/s/charming-jennings-ol4vl

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda