When using axios.get in Vue.js,

Asked 2 weeks ago, Updated 2 weeks ago, 3 views

Hello, I'm a developer who was developing the backend and started working on the front side this time. First of all, what I want to implement is to check the user's permission and display the administrator-only menu only. Flows currently implemented or planned to be implemented are as follows:

The problem that occurs at this time is whether the permission value received through communication is printed well on the console It doesn't work when checking permissions. (ex. Administrator page exposed even though you are a regular user) Therefore, when I tried to print the values I received from the communication on both the console and the template, I found that the valid values on the console were [object promiss] on the template. (Crying)

My prediction is that the template is sprayed after the axios.get communication before receiving the value...

Could you tell me my problem and solution? (Crying) Is there a way to wait for template rendering before receiving the value after communication? export defalt{ Create: If you declare it here, it will be executed before rendering, so even if you call the method here, it will not be resolved Please help me. }

vue node.js axios get session

2022-09-19 23:33

1 Answers

Axios returns the response result to Promise. Promise is an object associated with an asynchronous function in JavaScript.

If you study async function, wait, and Promise first, it will solve the problem. It's expected to be used incorrectly like a normal function.

2022-09-19 23:33

If you have any answers or tips

© 2022 pinfo. All rights reserved.