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

222
Views
Node.js - POST request won't execute until end of script

I'm trying to perform multiple POST requests in my code however the POST request will only occur when the script terminates. So far I've loaded the below code in via a function and imported the function as a module with no success.

I'm relatively new to node.js so I may be missing something obvious here. Does anyone have any ideas?

    var request = require('request');
    var options = {
        'method': 'POST',
        'url': 'https://XXXXXXXXXX.com/Example',
        'headers': {
            'Authorization': 'Basic SuperSecretPassword',
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        form: {
             'To': Receiver,
             'From': Sender,
             'Parameters': '{"Flag":"1","Duration":"5"}'
        }
    };


    request(options, function (error, response) {
        if (error) throw new Error(error);
        console.log(response.body);
    });

    console.log(options);
about 4 years ago · Santiago Trujillo
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!