Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
How to use data returned from an HTTP request using http-proxy-middleware and Express

I am making API calls to Squarespace for an inventory management system. I've set up a Node.js and Express server, and have been using http-proxy-middleware to set up a proxy and make GET requests.

I am able to generate the GET requests successfully on my localhost - an HTML pre-tag is filled with all of the JSON data of the request. However, I am completely clueless on how to handle and use the data further that was returned to me. When I make a call and receive Pending orders, I want to pull JSON data from the returned request body of the orders, such as SKU numbers for products purchased.

    const { response } = require('express');
    const express = require('express'); 
    require("dotenv").config();
    const { createProxyMiddleware, responseInterceptor } = require('http-proxy-middleware');
    const router = express.Router();

    const PORT = 3000; 
    const HOST = "localhost";
    const GET_ORDERS_URL = process.env.SS_GET_ORDERS_URL;
    const API_KEY = process.env.SS_AUTH;

    const app = express(); 

    const proxy = app.use("/testing", createProxyMiddleware({
        target: GET_ORDERS_URL,
        headers: {
            'Authorization': API_KEY,
            'User-Agent': 'halp me'
        },
        changeOrigin: true,
        pathRewrite: {
            [`^/testing`]: '',
        },
        selfHandleResponse: true, // 
        onProxyRes: responseInterceptor(async (responseBuffer, proxyRes, req, res) => {
          
            var orderResponse = responseBuffer.toString('utf-8');
            return orderResponse;
        }),
      }));


    // Start Proxy
    app.listen(PORT, HOST, () => {
        console.log(`Starting Proxy at ${HOST}:${PORT}`);
    });

The API request returns JSON data, which I would love to use and process for the next part of my inventory management. I'm trying to figure out why I can't get return orderResponse; to output anything at all.

I have tried every variation of returning a variable I can imagine, console.logged a million things - any guidance to what I'm missing here would be greatly appreciated!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!