1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | const assert = require('@polkadot/util/assert');
|
7 |
|
8 | module.exports = async function send({
|
9 | coder,
|
10 | endpoint
|
11 | }, method, params) {
|
12 | const body = coder.encodeJson(method, params);
|
13 | const response = await fetch(endpoint, {
|
14 | body,
|
15 | headers: {
|
16 | 'Accept': 'application/json',
|
17 | 'Content-Length': `${body.length}`,
|
18 | 'Content-Type': 'application/json'
|
19 | },
|
20 | method: 'POST'
|
21 | });
|
22 | assert(response.ok, `[${response.status}]: ${response.statusText}`);
|
23 | const result = await response.json();
|
24 | return coder.decodeResponse(result);
|
25 | }; |
\ | No newline at end of file |