'How can I pass answerId in action which I am dispatching and answerId is in response its an array object in arrayobject?

Consider:

private listenToAnswerDeleted() {
   this.uiService.onGlobalEvent('ANSWER_DELETED').subscribe((response) => {
       this.store.dispatch(deleteAnswerAction({'answerId': }));
   });
}

In response, I am receiving answerId which I want to pass as a parameter in the action which I am dispatching its and array object


response = {name: 'ANSWER_DELETED', extras: {…}}
extras: {answerId: 'sa68f-k3h45-yi35uy'}
name: "ANSWER_DELETED"
[[Prototype]]: Object


Solution 1:[1]

private listenToAnswerDeleted() {
    this.uiService.onGlobalEvent('ANSWER_DELETED').subscribe((response) => {
        const {answerId} = response.extras;
        this.store.dispatch(deleteAnswerAction({answerId}));
    });
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Peter Mortensen