Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

53
Views
How to return a jobID in Kue?

I am using express, and want to create a job anytime someone posts to my route. I would like the response to contain the job.id. However, the job id only populates in the callback of my queue.createFunction, so I am not quite sure how to return the job id? One solution I can think of is issuing a post request in my route to create a job, as their api returns an id as a response, but this seems inefficient.

8 months ago · Santiago Trujillo
1 answers
Answer question

0

Not 100% if this answers your question but I've used the below to create a job on a POST request before:

const queue = kue.createQueue({
  redis: {
    port: conf.redis_port,
    host: conf.redis_host,
  },
})

app.post('endpoint', function(req, res, next) {
    let job = queue.create('some_action', req.data)

    // ... add job listeners etc.

    job.save(function(err) {
        if (err) {
            return res.send({ error: err })
        } else {
            return res.send({ id: job.id })
        }
    })

})

Hope it helps! :)

8 months ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.