mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
30 lines
700 B
TypeScript
30 lines
700 B
TypeScript
import fetch from "node-fetch"
|
|
import { URL } from "url"
|
|
|
|
export default class AquariusConnector {
|
|
|
|
public post(url, payload) {
|
|
return fetch(url, {
|
|
method: "POST",
|
|
body: payload,
|
|
headers: {
|
|
"Content-type": "application/json",
|
|
},
|
|
})
|
|
}
|
|
|
|
public get(url, payload) {
|
|
const fullUrl = new URL(url)
|
|
for (const key of Object.keys(payload)) {
|
|
fullUrl.searchParams.append(key, payload[key])
|
|
}
|
|
return fetch(fullUrl, {
|
|
method: "GET",
|
|
body: null,
|
|
headers: {
|
|
"Content-type": "application/json",
|
|
},
|
|
})
|
|
}
|
|
}
|