Is there a way to use const { data } = await axios.get(insertthinghere);
multiple times?
Trying to use AXIOS to get stuff from APIs, using the code above works once however when trying to use it again, it throws an error.
Cannot redeclare block-scoped variable 'data'
Trying to change data to anything else also doesn't work.
Example of what I'm trying to do with placeholder names.
let api1 = "INSERTAPILINKHERE";
if (args.length) {
api1 += `/++${args[0]}`;
}
const { data } = await axios.get(api1);
var variable1 = JSON.stringify(data);
variable1 = variable1.replace(/\D/g, "");
let api2 = "ANOTHERDIFFERENTAPILINK";
if (args.length) {
api2 += `/++${args[0]}`;
}
const { data2 } = await axios.get(api2);
const parsedJSON = JSON.parse(data2);
var valueFromJSON = parsedJSON.somevalue;