How do you send data to a promise invocation? #1329
Answered
by
davidkpiano
mattpeskett
asked this question in
General
-
I'm using services that return promises extensively in my state machine. I'd like to send arguments to those services to perform some basic routing logic but I can't see a way to send arguments to those promises. Is there a way I can achieve this? |
Beta Was this translation helpful? Give feedback.
Answered by
davidkpiano
Jul 23, 2020
Replies: 1 comment 8 replies
-
You can use // ...
invoke: {
src: 'fetchUser',
data: { id: (ctx) => ctx.userId }
},
// ...
services: {
fetchUser: (ctx, event, { data }) => {
return fetchUserFromAPI(data.id);
}
} Or do you mean something else? Can you show in code what you want to do? |
Beta Was this translation helpful? Give feedback.
8 replies
Answer selected by
mattpeskett
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use
data
to do that:Or do you mean something else? Can you show in code what you want to do?