JSFiddle - React, Tailwind, and code Playground
HTML
json data URL: <input type="text" style="width:300px;" value="http://pin-codes.in/api/pincode/400001/"><button onclick="fetch(this.previousSibling.value);">Fetch</button><br>
<hr>output div:<br>
<div id="output"></div>
JavaScript
function getJSON(url) { //quick and dirty
var script = document.createElement('script');
script.setAttribute('src', url);
script.setAttribute('type', 'text/javascript');
document.getElementsByTagName('head')[0].appendChild(script);
}
function cbfunc(json){
if(json.query.count){
var data=json.query.results.json;
document.getElementById('output').innerHTML=data.toSource();
} else {
alert('Error: nothing found'); return false;
}
}
function fetch(url){
var yql="select * " +
" from json" +
" where url='" + url + "';";
yql="http://query.yahooapis.com/v1/public/yql?q=" +
encodeURIComponent(yql) +
"&format=json" +
"&callback=cbfunc";
getJSON(yql);
}