1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00
squid-js/src/utils/WebServiceConnector.ts
2018-11-19 12:16:11 +01:00

38 lines
871 B
TypeScript

import fetch from "node-fetch"
export default class WebServiceConnector {
public async post(url, payload): Promise<any> {
return this.fetch(url, {
method: "POST",
body: payload,
headers: {
"Content-type": "application/json",
},
})
}
public async get(url): Promise<any> {
return this.fetch(url, {
method: "GET",
headers: {
"Content-type": "application/json",
},
})
}
public async put(url, payload): Promise<any> {
return this.fetch(url, {
method: "PUT",
body: payload,
headers: {
"Content-type": "application/json",
},
})
}
private async fetch(url, opts): Promise<any> {
return fetch(url, opts)
}
}