Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 3x 3x 7x 7x 7x 7x 7x 7x 3x | import HeaderMap from 'http/type/header-map';
import StatusCode from 'http/enum/status-code';
import JsonObject from 'http/type/json-object';
import ContentType from 'http/enum/content-type';
import postBuffer from 'http/utility/post-buffer';
interface ResponseData {
body: JsonObject;
headers: HeaderMap;
status_code: StatusCode;
}
async function postJson(url: string, data: JsonObject): Promise<ResponseData> {
const serialized_data = JSON.stringify(data);
const buffer = Buffer.from(serialized_data);
const result = await postBuffer(url, ContentType.JSON, buffer);
const string_body = result.body.toString('utf8');
const body = JSON.parse(string_body);
return {
...result,
body
};
}
export default postJson;
|