Small issue in the mirage config and once that was fixed the application template wasn’t be displaying the right things in the dropdown. I got the dropdown list part working, here’s a git diff:
--- a/app/pods/application/template.hbs
+++ b/app/pods/application/template.hbs
@@ -14,8 +14,8 @@
{{/if}}
<ul>
- {{#each searchRepo.lastSuccessful.value as |repo|}}
- <li>{{repo.full_name}}</li>
+ {{#each searchRepo.lastSuccessful.value as |term|}}
+ <li>{{term.term}}</li>
{{/each}}
</ul>
</div>
diff --git a/mirage/config.js b/mirage/config.js
index f2464d4..9c2d59c 100755
--- a/mirage/config.js
+++ b/mirage/config.js
@@ -1,12 +1,12 @@
export default function() {
this.namespace = "api";
-this.get("/terms", function({ terms }, { queryParams }) {
-
- let { term } = queryParams;
- if (term) {
- const match = term.toLowerCase();
- terms = terms.filter(t => t.term.toLowerCase().includes( match ));
- }
- return terms;
-});
+ this.get("/terms", function({ terms }, { queryParams }) {
+ let { term } = queryParams;
+ let results = terms.all();
+ if (term) {
+ const match = term.toLowerCase();
+ results = results.filter(t => t.term.toLowerCase().includes(match));
+ }
+ return results;
+ });
}
Basically my original snipped a couple comments ago was overloading “terms” which caused an error so I changed it to “results”. And then a tweak to the template to match the models being returned.