[Vuejs]-Event emitters parameter is undefined for listener Vue js

0👍

Here in the below code:

eventhub.$emit('post-added', response.body)

response.body is undefined. This is because body isn’t a field exposed in the response for the request (This response schema is specific to the axios client.)1

Assuming that after making the HTTP POST request, the server returns a response that you’ll like to process in the client.

That response data can be retrieved in the data field of the response in the following manner.

eventhub.$emit('post-added', response.data)

Leave a comment