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

140
Views
Running multiple instance Async functions in expressjs

Lets say I have a expressjs site up and I have a 2-3 second runtime async function, how am I able to run multiple instances without returning errors and overlapping data if the functions were called at the same time.

app.set('view engine', 'ejs');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use('/css', express.static(__dirname + 'public/css'));
app.use('/img', express.static(__dirname + 'public/img'));
app.use('/public', express.static('public'));

app.get('/', function(req, res) {
  res.render('index');
});
app.get('/faq', function(req, res){
    res.render('faq');
})
app.get('/contact', function(req, res){
    res.render('contact');
})
app.get('/submitorder', function(req, res){
    res.render('submitorder');
})

app.post('/order', async function(req,res){
    var data = fs.readFileSync('tokens.txt', 'utf-8');
    if(data.includes(req.body.token)){
        var newValue = data.replace(new RegExp(req.body.token), "");
        newValue.replace(/^\s*\n/gm, "");
        fs.writeFileSync('tokens.txt', newValue, 'utf-8');
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!