import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {SirenEntityMixin} from './siren-entity-mixin.js';
import {html} from '@polymer/polymer/lib/utils/html-tag.js';
import './notes/note.js';

class MyVirtualNotebook extends SirenEntityMixin(PolymerElement) {

	static get template() {
		return html`
<h1>My Virtual Notebook</h1>
<template is="dom-repeat" items="[[notes]]">
	<d2l-note href="{{item}}" token="{{token}}"></d2l-note>
</template>
`;
	}

	static get properties() {
		return {
			notes: {
				type: Array,
				value: []
			}
		};
	}

	static get observers() {
		return [
			'_changed(entity)'
		];
	}

	static get is() {
		return 'my-virtual-notebook';
	}

	_changed() {
		this._getUrlForNotes(this.href);
	}

	async _getUrlForNotes(href) {
		const response = await fetch(href)
			.then(res => res.json());
		this.notes = response.entities.map(e => e.href);
	}
}

window.customElements.define(MyVirtualNotebook.is, MyVirtualNotebook);

@@ -697,148 +697,55 @@
 ged(
-) %7B%0A%09%09this._getUrlForNotes(this.href);%0A%09%7D%0A%0A%09async _getUrlForNotes(href) %7B%0A%09%09const response = await fetch(href)%0A%09%09%09.then(res =%3E res.json());%0A
+entity) %7B%0A%09%09if( entity && entity.entities ) %7B%0A%09
 %09%09th
@@ -759,16 +759,14 @@
 s = 
-response
+entity
 .ent
@@ -779,22 +779,38 @@
 map(
-e =%3E e
+subEntity =%3E subEntity
 .href);%0A
 %09%7D%0A%7D
@@ -805,16 +805,20 @@
 .href);%0A
+%09%09%7D%0A
 %09%7D%0A%7D%0A%0Awi

Use entity from SirenEntityMixin instead of fetch/parsing itself