node http2 post

Solutions on MaxInterview for node http2 post by the best coders in the world

showing results for - "node http2 post"
Angelo
08 Jan 2017
1     let res = "";
2      let postbody = JSON.stringify({
3       key: value
4      });
5      let baseurl = 'baseurl'
6      let path = '/any-path'
7      const client = http2.connect(baseurl);
8      const req = client.request({
9       ":method": "POST",
10       ":path": path,
11       "content-type": "application/json",
12       "content-length": Buffer.byteLength(postbody),
13      });
14
15
16      req.on("response", (headers, flags) => {
17       for (const name in headers) {
18        console.log(`${name}: ${headers[name]}`);
19       }
20
21      });
22      req.on("data", chunk => {
23       res = res + chunk;
24      });
25      req.on("end", () => {
26       client.close();
27      });
28
29   req.end(postbody)
30
similar questions
queries leading to this page
node http2 post