1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

move getData() function to Provider

This commit is contained in:
Miquel A. Cabot 2022-06-09 13:17:45 +02:00
parent cd34833ff7
commit 28ddcdaa3d
2 changed files with 11 additions and 11 deletions

View File

@ -1,6 +1,6 @@
import Web3 from 'web3'
import fetch from 'cross-fetch'
import { LoggerInstance, getData } from '../utils'
import { LoggerInstance } from '../utils'
import {
FileMetadata,
ComputeJob,
@ -21,7 +21,7 @@ export class Provider {
*/
async getEndpoints(providerUri: string): Promise<any> {
try {
const endpoints = await getData(providerUri)
const endpoints = await this.getData(providerUri)
return await endpoints.json()
} catch (e) {
LoggerInstance.error('Finding the service endpoints failed:', e)
@ -802,6 +802,15 @@ export class Provider {
}
return { valid: true, output: match[1] }
}
private async getData(url: string): Promise<Response> {
return fetch(url, {
method: 'GET',
headers: {
'Content-type': 'application/json'
}
})
}
}
export const ProviderInstance = new Provider()

View File

@ -43,15 +43,6 @@ export async function downloadFile(
return { data: await response.arrayBuffer(), filename }
}
export async function getData(url: string): Promise<Response> {
return fetch(url, {
method: 'GET',
headers: {
'Content-type': 'application/json'
}
})
}
async function postWithHeaders(
url: string,
payload: BodyInit,