2018-10-26 11:57:26 +02:00
|
|
|
import fetch from "node-fetch"
|
|
|
|
|
2018-11-19 12:16:11 +01:00
|
|
|
export default class WebServiceConnector {
|
2018-10-26 11:57:26 +02:00
|
|
|
|
2018-11-01 12:47:48 +01:00
|
|
|
public async post(url, payload): Promise<any> {
|
|
|
|
return this.fetch(url, {
|
2018-10-26 11:57:26 +02:00
|
|
|
method: "POST",
|
|
|
|
body: payload,
|
2018-11-16 10:03:16 +01:00
|
|
|
headers: {
|
|
|
|
"Content-type": "application/json",
|
|
|
|
},
|
2018-10-26 11:57:26 +02:00
|
|
|
})
|
|
|
|
}
|
2018-10-29 16:38:23 +01:00
|
|
|
|
2018-11-01 12:47:48 +01:00
|
|
|
public async get(url): Promise<any> {
|
|
|
|
return this.fetch(url, {
|
2018-10-29 16:38:23 +01:00
|
|
|
method: "GET",
|
2018-11-16 10:03:16 +01:00
|
|
|
headers: {
|
|
|
|
"Content-type": "application/json",
|
|
|
|
},
|
2018-10-29 16:38:23 +01:00
|
|
|
})
|
|
|
|
}
|
2018-11-01 12:47:48 +01:00
|
|
|
|
|
|
|
public async put(url, payload): Promise<any> {
|
|
|
|
return this.fetch(url, {
|
|
|
|
method: "PUT",
|
|
|
|
body: payload,
|
2018-11-16 10:03:16 +01:00
|
|
|
headers: {
|
|
|
|
"Content-type": "application/json",
|
|
|
|
},
|
2018-11-01 12:47:48 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
private async fetch(url, opts): Promise<any> {
|
|
|
|
return fetch(url, opts)
|
|
|
|
}
|
2018-10-26 11:57:26 +02:00
|
|
|
}
|