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

218
Views
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 answers
Answer question

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 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!