Skip to content
Advertisement

Vue js send data from api to new page

I am new to Vue Js and I would like to know how I can send data between two components. I am building a vue app that gets a list of users from an api and displays them. I would like to know I can move data between two components so that I can view more details on a new page.

here is my html code to display the data in a table

JavaScript

this is my js code

JavaScript

where do how I move the data to the view and edit routes/components

Advertisement

Answer

You can use vue-router’s dynamic route matching for this kind of problem. You can simply refactor your /user endpoint to /user/:id and in the component you are calling when landing on /user, you can simply make your api call and fill in the details. You need to update your first router link to have some id in the form of: /user/123 and in the component, you can get that id by calling this.$route.params.id.

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