Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

216
Vistas
How do I use an external API in my React project?

Apologies for the duplicate question I'm sure this has been asked many times before.

I'm using React, Express, CORS, node, postgres. I would like to use the following api to retrieve live price for metals:

https://metals-api.com/

I can use my API with my test app, I would also like in addition to use the API from above

const express = require('express');
const app = express();
const cors = require("cors");
const pool = require("./db");

//middleware
app.use(cors());
app.use(express.json());

//ROUTES

And here is one of my example routes:

//Add entry to contact table
app.post("/contact", async (req, res) => {
    try {

        const {scontact_name} = req.body;
        const newContactName = await pool.query(
            'INSERT INTO supplier_contacts (scontact_name) VALUES ($1)', [scontact_name]);

        res.json(newContactName);

    } catch (err) {
        console.error(err.message);
    }
})

So to clarify there is my local API used to communicate with the postgres db. In addition I would like to use the api linked above to get some price information, help is much appreciated!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Javascript has a build-in fetch method (see here) You can also use any 3rd party libary, for example axios

You can easily call their methods in a async function and then do what ever you whish with the response.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda