Agenda: Passing both a callback and data to agenda.now() at the same time throws an error

Created on 22 Sep 2018  路  5Comments  路  Source: agenda/agenda

I'm trying to schedule a job to run with agenda.now() while passing some data to jobs.attrs.data:

agenda.now('myJob', { data: data }, (error, jobSaved) => {
    if (error) {
        console.error("Error saving job: ", error);
        res.send(error);
    } else {
        console.log("The job was correctly saved!");
        res.sendStatus(200);
    }
};

But this throws an error:
Error: This function does not accept a callback function. 3/2

If I run this with only the data or only the callback, it runs correctly, but passing them both throws the error.

I'm using the exact structure in agenda.schedule() and agenda.every() with the same data and callback, and everything's running fine. It's just the now() function.

Am I missing something?

Most helpful comment

It looks like agenda got a rewrite with promises and the documentation wasn't updated. Callbacks are no longer accepted.

https://github.com/agenda/agenda/commit/b9ecca90916abc88c95d5f229a3fa21c7e356504#r30854923

All 5 comments

It looks like agenda got a rewrite with promises and the documentation wasn't updated. Callbacks are no longer accepted.

https://github.com/agenda/agenda/commit/b9ecca90916abc88c95d5f229a3fa21c7e356504#r30854923

That was it, thanks a lot!

indeed - it's time to change this:

https://github.com/agenda/agenda#nowname-data-cb

indeed - it's time to change this:

https://github.com/agenda/agenda#nowname-data-cb

I agree. https://github.com/agenda/agenda/pull/831

Docs updated 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ephigabay picture ephigabay  路  5Comments

ruslanjur picture ruslanjur  路  4Comments

exislow picture exislow  路  5Comments

samhagman picture samhagman  路  6Comments

jodevsa picture jodevsa  路  4Comments