'Call an API inside another API - Node.js with Mongoose

I have an API with certain routes for a company, example:

// Company
routes.get("/company", companyController.getCompanies); // Obter todas as empresas
routes.post("/company", companyController.saveCompany); // Registar uma empresa

And a company class has this:

const Company = mongoose.Schema(
  {
    name : { type: String, required: true },
    description : { type: String, required: true },
    location : { type: String, required: true },
    numberOfEmployees: { type: Number, required: false },
    subjectAreas: { type: String, required: true },
    username : { type: String, required: true },
    email : { type: String, required: true },
    password : { type: String, required: true }
  }
)

But now I want to know the weather in the company location. Do I need to create another route with my API? Where can I start? I'm thinking about using Accuweather API but have no idea how to start. Any help?

I'm using node.js, javascript



Solution 1:[1]

Simple you can call Accuweather API inside your current controller and save the response in DB

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 afsal