PicList/src/universal/utils/getLatestVersion.ts

21 lines
624 B
TypeScript
Raw Normal View History

import axios from 'axios'
import yaml from 'js-yaml'
import { RELEASE_URL, RELEASE_URL_BACKUP } from './static'
export const getLatestVersion = async (): Promise<string> => {
try {
2023-05-18 06:23:56 -04:00
const { data: normalList } = await axios.get(RELEASE_URL)
return normalList[0].name
} catch (err) {
console.error('Error fetching latest version: ', err)
try {
const { data } = await axios.get(`${RELEASE_URL_BACKUP}/latest.yml`)
const r = yaml.load(data) as IStringKeyMap
return r.version
} catch (err) {
console.error('Error fetching backup latest version: ', err)
return ''
}
}
}