Skip to content

Instantly share code, notes, and snippets.

@egyjs
Created October 31, 2017 19:48
Show Gist options
  • Save egyjs/fa3bca2ab47ee6dcb932fdd81dc75d04 to your computer and use it in GitHub Desktop.
Save egyjs/fa3bca2ab47ee6dcb932fdd81dc75d04 to your computer and use it in GitHub Desktop.
shorte.st api javascript
<input type="text" maxlength="512" id="searchTxt" class="searchField"/>
<input type="button" value="Get Value" onclick="cut(searchTxt.value)">
<script>
function cut(myurl){
$.ajax({
url:"https://api.shorte.st/v1/data/url",
type:"put",
async:true,
crossDomain:true,
dataType:"json",
data:{urlToShorten: myurl},
accepts:{
"*": "*/*",
text: "text/plain",
html: "text/html",
xml: "application/xml, text/xml",
json: "application/json, text/javascript"
},
headers: {'public-api-token':'b86592121c395b7494c792805e736b09'},
success: function(result) {
console.log(result);
},
error: function(request,msg,error) {
console.log(error);
}
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment