Home > Software engineering >  Vue design question about api calls / emitting
Vue design question about api calls / emitting

Time:03-19

Is better to make your API calls in, App and have pages/components emit requests then get pushed the data.

Or

To have the API ol at the page level. Fewer emits but more redundancy.

For example


App ‐-----------------page1 - component1
(Apicall1, apicall2)  page2 - component1
                      Page3 - component1&
                              Component2

App - page1 (api1) - component1 
      Page2 (api2) - component2
      Page3 (api1, api2) - component1 & 
                           component2
       

Was hoping to feedback as to the best theory for sites that will grow over time.

CodePudding user response:

If you already know that the site will grow over time, I would use a centralized store (Vuex or Pinia). Maybe now is not strictly needed, but over time you'll be glad you made that decision early.

  • Related