1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00
squid-js/src/aquarius/AquariusConnector.ts

30 lines
700 B
TypeScript
Raw Normal View History

2018-10-26 11:57:26 +02:00
import fetch from "node-fetch"
2018-10-29 16:55:32 +01:00
import { URL } from "url"
2018-10-26 11:57:26 +02:00
export default class AquariusConnector {
public post(url, payload) {
return fetch(url, {
method: "POST",
body: payload,
headers: {
"Content-type": "application/json",
},
})
}
2018-10-29 16:38:23 +01:00
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",
},
})
}
2018-10-26 11:57:26 +02:00
}