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

remove unused functions from FetchHelper

This commit is contained in:
Miquel A. Cabot 2022-06-09 13:18:46 +02:00
parent 28ddcdaa3d
commit 4cfcd3c20d

View File

@ -1,16 +1,5 @@
import fetch from 'cross-fetch'
import { DownloadResponse } from '../@types'
import { LoggerInstance } from '.'
export async function fetchData(url: string, opts: RequestInit): Promise<Response> {
const result = await fetch(url, opts)
if (!result.ok) {
LoggerInstance.error(`Error requesting [${opts.method}] ${url}`)
LoggerInstance.error(`Response message: \n${await result.text()}`)
throw result
}
return result
}
export async function downloadFileBrowser(url: string): Promise<void> {
const anchor = document.createElement('a')
@ -42,28 +31,3 @@ export async function downloadFile(
return { data: await response.arrayBuffer(), filename }
}
async function postWithHeaders(
url: string,
payload: BodyInit,
headers: any
): Promise<Response> {
if (payload != null) {
return fetch(url, {
method: 'POST',
body: payload,
headers
})
} else {
return fetch(url, {
method: 'POST'
})
}
}
export async function postData(url: string, payload: BodyInit): Promise<Response> {
const headers = {
'Content-type': 'application/json'
}
return postWithHeaders(url, payload, headers)
}