mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
16 lines
390 B
TypeScript
16 lines
390 B
TypeScript
|
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)
|
||
|
}
|
||
|
}
|