Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

http get response body node js

Tomer Mantzuri answered on May 26, 2022 Popularity 9/10 Helpfulness 4/10

Contents


More Related Answers

  • How to parse POST requests with express nodejs
  • send a request using node js
  • node http post
  • How to access the request body when POSTing using Node.js and Express
  • req body express
  • express get body
  • nodejs request api
  • read body of post request nodejs
  • nodejs request
  • make a get request in node js
  • nodejs call api
  • node red http post request data
  • node js http request
  • nodejs response message
  • node http server return json
  • req.body in express
  • how to send response to client in nodejs using res object
  • how to create request body javascript
  • req body express
  • get post data in node api
  • node js do request
  • how to get json response from rest api in node js
  • Get Request Node HTTP
  • request html nodejs
  • http request node.js
  • how to get json response from rest api in node js
  • request get response node js
  • node js http post request

  • http get response body node js

    0
    Popularity 9/10 Helpfulness 4/10 Language javascript
    Link to this answer
    Share Copy Link
    Contributed on May 26 2022
    Tomer Mantzuri
    0 Answers  Avg Quality 2/10

    Closely Related Answers



    0
    Popularity 9/10 Helpfulness 6/10 Language javascript
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Sep 11 2023
    YOU.com
    0 Answers  Avg Quality 2/10

    -1

    // File: `pages/api/webhooks/someProvider.ts`

    import type { NextApiRequest, NextApiResponse } from 'next';

    import type { Readable } from 'node:stream';

    // EXPORT config to tell Next.js NOT to parse the body

    export const config = {

    api: {

    bodyParser: false,

    },

    };

    // Get raw body as string

    async function getRawBody(readable: Readable): Promise {

    const chunks = [];

    for await (const chunk of readable) {

    chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk);

    }

    return Buffer.concat(chunks);

    }

    // API handler function

    export default async function handler(req: NextApiRequest, res: NextApiResponse) {

    const rawBody = await getRawBody(req);

    console.log('raw body for this request is:', rawBody);

    const data = JSON.parse(Buffer.from(rawBody).toString('utf8'));

    console.log('json data for this request is:', data);

    res.send('Got raw body!');

    }  

    Popularity 9/10 Helpfulness 1/10 Language javascript
    Link to this answer
    Share Copy Link
    Contributed on Jun 02 2023
    Strange Snake
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.