Skip to content
Advertisement

How to spread an object as individual arguments in a function whose declaration I cannot change?

I have an object with some properties such as;

JavaScript

I am passing this object to a function below as shown (attachments is not important).

JavaScript

Importantly, this function is part of an NPM Package, so I don’t want to change the function declaration.

The function is declared like this:

JavaScript

I put some breakpoint to the pushToSlack function but the debugger didn’t jump into that line. I guess the function is not called somehow. I also receive this error:

JavaScript

Have you got any idea?

Advertisement

Answer

Spread syntax is not usable for that
use Destructuring assignment

JavaScript

the call :

JavaScript

the function :

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement