Creating a type that accepts a generic map #1928
Answered
by
EmilTholin
bradherman
asked this question in
Q&A
-
The API I'm working with uses Rails on the backend and serializes the errors into a generic map of
If the payload looks like this:
how can I define my Error model to accept the errors attribute directly knowing the keys in the map will be dynamic?
|
Beta Was this translation helpful? Give feedback.
Answered by
EmilTholin
Jul 12, 2022
Replies: 1 comment 1 reply
-
Hi @bradherman! You could model it as a map of array of strings: export const Error = types.model('Error', {
errors: types.map(types.array(types.string)),
}) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
EmilTholin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @bradherman!
You could model it as a map of array of strings: