Good day, I'm trying to learn how to build a certain application but I need some help or at least some documentation about what I'm trying to do.
I already have my node.js/express.js ready to listen and serve what I can ask.
My next step which is where I struggle I need to call an API to pipe this API back into a response.
What I want to achieve:
I have a Google Sheet that calls an API already, but some time this API is down and I need to call a second one. Both have different structure so I'm trying to create my own API (Basically piping one of those 2 API) to pass it to my Google Sheet the way I want it.
What I've accomplish, I can call the API and pass the response to the console, but I haven't been able to find a way to pass this response back to a browser for example (res.send(response)) it normally gives me some asynchronous errors
import 'dotenv/config';
import cors from 'cors';
import express from 'express';
import axios from 'axios';
const app=express();
const https=require("https");
const url="https://jsonplaceholder.typicode.com/todos/1"
app.use(cors());
app.get('/', (req, res) => {
axios.get(url)
.then(function(response){
res.send(response);
})
.catch(function(error){
console.log(error);
})
});
app.listen(process.env.PORT, () =>
console.log('App listening on port '+process.env.PORT),
);
TypeError: Converting circular structure to JSON
That's the error I keep getting.
I'm using Axios in that example but I have tried other solution too but I can't seem to find a way to do it.
I'm a beginner with all of this, I tried many search on google already but I don't know the proper wording for what I'm looking to do :-/
So quick recap
API1 or API2 return their response > I Manipulate their response > I send the response back to my own application