Created
September 18, 2018 07:45
-
-
Save pbuzdin/4fa503a1c0b565bbd4f501214ed54ce4 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/muzamos
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script> | |
</head> | |
<body> | |
<div id="divContent"> | |
<h1>Article Search Results</h1> | |
<form v-on:submit.prevent="search"> | |
<input type="text" v-model="query"> | |
<button type="submit">Search</button> | |
</form> | |
<ul> | |
<li v-for="article in articles" v-bind:key="article.source + article.id"> | |
{{ article.title }} | |
</li> | |
</ul> | |
</div> | |
<script id="jsbin-javascript"> | |
const vm = new Vue({ | |
el: '#divContent', | |
data() { | |
return { | |
query: 'gene', | |
articles: 'loading' | |
} | |
}, | |
created() { | |
this.search(); | |
}, | |
methods: { | |
search: function () { | |
fetch(`https://www.ebi.ac.uk/europepmc/webservices/rest/search?query=${this.query}&format=json`) | |
.then(response => response.json()) | |
.then(json => { | |
this.articles = json.resultList.result; | |
}); | |
} | |
} | |
}); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">const vm = new Vue({ | |
el: '#divContent', | |
data() { | |
return { | |
query: 'gene', | |
articles: 'loading' | |
} | |
}, | |
created() { | |
this.search(); | |
}, | |
methods: { | |
search: function () { | |
fetch(`https://www.ebi.ac.uk/europepmc/webservices/rest/search?query=${this.query}&format=json`) | |
.then(response => response.json()) | |
.then(json => { | |
this.articles = json.resultList.result; | |
}); | |
} | |
} | |
}); | |
</script></body> | |
</html> |
This file contains 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
const vm = new Vue({ | |
el: '#divContent', | |
data() { | |
return { | |
query: 'gene', | |
articles: 'loading' | |
} | |
}, | |
created() { | |
this.search(); | |
}, | |
methods: { | |
search: function () { | |
fetch(`https://www.ebi.ac.uk/europepmc/webservices/rest/search?query=${this.query}&format=json`) | |
.then(response => response.json()) | |
.then(json => { | |
this.articles = json.resultList.result; | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment