This is a very basic example, as Wikipedia does not require authentification. It displays the content of the Wikipedia article with the given name.
Datasource
Datasource type | REST Custom |
---|
Datasource URL | https://en.wikipedia.org/w/api.php
|
---|
Datasource Test URL | ?action=parse&page=Vancouver&format=json
|
---|
Query
Query URL | ?action=parse&page=:Title&format=json
|
---|
Example parameters | |
---|
Raw result |
{
"parse":{
"title":"Vancouver",
"pageid":32706,
"revid":1076947989,
"text":{
"*":"HTML_CONTENT"
},
"FURTHER_CONTENT_OMITTED": ""
}
}
CODE
|
---|
Converter
function convert(json) {
var parsedJsonObject = JSON.parse(json);
var wikipediaContent = parsedJsonObject.parse.text['*'];
return [{ "wikipediaContent": wikipediaContent }];
}
JS
Template
We want to display the HTML content from Wikipedia that we can find in our JSON result. We also want to use the styles from Wikipedia.
<link rel="stylesheet" href="https://en.wikipedia.org/w/load.php?debug=false&lang=en&modules=site.styles&only=styles&skin=vector">
$result.get(0).wikipediaContent
CODE