1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00
market/src/@utils/fetch.ts

16 lines
390 B
TypeScript
Raw Normal View History

2021-10-13 18:48:59 +02:00
import axios, { AxiosResponse } from 'axios'
export async function fetchData(url: string): Promise<AxiosResponse['data']> {
try {
const response = await axios(url)
if (response.status !== 200) {
return console.error('Non-200 response: ' + response.status)
}
return response.data
} catch (error) {
console.error('Error parsing json: ' + error.message)
}
}