Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4836

How to 'async model' hook followed by 'setupController' hook

$
0
0

I am trying to pass route params to my controller via the ‘setupController’ hook in my route handler.

First I’m referenced the (https://guides.emberjs.com/release/routing/specifying-a-routes-model/) documentation on setting up an API call via **async model **in my route handler to incorporate the route params for my initial data fetch but need these variables passed onto the controller.

Currently adding the setupController hook after async model

  async model(params) {
const response = await fetch(`/my-cool-end-point.json${params.id}`);
const photos = await response.json();

return { photos };
  }

Gives me a repeated error Cannot access 'params' before initialization

Any advice on how to improve my referencing here in order to find the desired documentation would be greatly appreciated.

Thanks

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4836

Trending Articles