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

212
Views
pass value from input to node js http request parameter

greeting kings

i have api request that have cors problem. I'm able to solve by using proxy setup using nodejs. Unfortunately im trying to pass certain query parameter from my main js to app.js(nodejs proxy) so my api can have certain value from main js. How to solve this or should point me where should i read more.below is my code

main js

const inputValue = document.querySelector('input').value

//this value is maybeline

app.js(node.js proxy)

const express = require('express')
const request = require('request');
const app = express()


app.use((req,res,next)=>{
    res.header('Access-Control-Allow-Origin', '*');
    next();
})


app.get('/api', (req, res) => {
    request(
        { url: 'https://makeup-api.herokuapp.com/api/v1/products.json?brand=covergirl' },
        (error, response, body) => {
            if (error || response.statusCode !== 200) {
                return res.status(500).json({ type: 'error', message: err.message });
            }

            res.json(JSON.parse(body));
        }
    )
});

const port = process.env.PORT || 5500

app.listen(5500,()=>console.log(`listening ${port}`))

I want to pass inputValue as query to api in app.js

as

https://makeup-api.herokuapp.com/api/v1/products.json?brand=${type}

How to do it or point me any direction?

note:this api work withour cors problem.This is an example api..tq

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use stringify method from qs module.

const { stringify } = require("qs");

app.get("/api", (req, res) => {
  request(
    {
      url: `https://makeup-api.herokuapp.com/api/v1/products.json?${stringify(
        req.params
      )}`,
    }
        /// Rest of the code
      );
    });
about 4 years ago · Juan Pablo Isaza Report
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!