Breeze retrieves metadata if not

I have an angular / breeze / webapi application that works fine unless I refresh the page where EntityQuery returns a single object. He then complains that the metadata is not available, since the request object does not start the selection of metadata, unlike the standard request.

If we reached the page from the previous angular page that issued the standard breeze request, then metadata already exists and we have no problem.

So, the question is, how can I check for metadata and call metadata if it has not already been completed?

Thanks so much for any help you can give me.

+3
source share
1 answer

Try something like this:

function fetchMetadata() { var manager = new breeze.EntityManager("api/breeze"); if (manager.metadataStore.isEmpty()) { return manager.fetchMetadata(); } return Q.resolve(); } function start() { fetchMetadata().then(function () { // Metadata fetched. // Do something here. }); } 
+6
source

All Articles