Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

173
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda