You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
926 B

import axios from 'axios';
export default async function (url: string): Promise<string> {
console.log(url);
return axios.get(url).then((res: any) => {
const tags: string | any[] = [];
for (const key in res.data.paths) {
if (Object.prototype.hasOwnProperty.call(res.data.paths, key)) {
const element = res.data.paths[key];
for (const key in element) {
if (Object.prototype.hasOwnProperty.call(element, key)) {
const innerElement = element[key];
console.log(innerElement);
if (
innerElement?.tags?.length > 0 &&
!tags.includes(innerElement.tags[0])
) {
tags.push(innerElement.tags[0]);
}
}
}
}
}
return JSON.stringify({
...res.data,
tags: tags?.map((item) => {
return {
name: item,
};
}),
});
});
}