A Pen by Jeremy Prevost on CodePen.
Created
April 30, 2020 21:26
-
-
Save JPrevost/188dd9ed9e3733ef58ddbfea7d3db4ec to your computer and use it in GitHub Desktop.
vYNeNbO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Hello TIMDEX!</h1> | |
<div id="app"> | |
<input type="text" v-model="term"> | |
Term: {{ term }} | |
<div v-if="results!=null"> | |
Hits: {{ results.hits }} | |
Limit: {{ results.request_count }} / {{ results.request_limit }} | |
<div class="results" v-for="item in results.results"> | |
<div class="item"> | |
<ul> | |
<li>{{ item.source }}</li> | |
<li>{{ item.title }}</li> | |
<li><a v-bind:href="item.source_link">View Soure Record</a></li> | |
</ul> | |
</div> | |
</div> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = new Vue ({ | |
el: '#app', | |
data: { | |
results: null, | |
term: null | |
}, | |
watch: { | |
term: function() { | |
fetch('https://timdex.mit.edu/api/v1/search?q=' + this.term) | |
.then(response => response.json()) | |
.then(data => { | |
this.results = data; | |
}) | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment