This shortens a link and returns it as a JSON object. Follow the steps below to use the API.
~ include the below JQUERY library in your header:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>~ Send a post request to urlq.herokuapp.com url:'/getlink' having JSON data as follows:
~ {link : theLinkToBeShortened}
~ Example:
$.ajax({
type: "POST",
url: "urlq.herokuapp.com/getlink",
data: {url: theUrlToBeShortened}, // URL
dataType: "json", // indicates response is in JSON format
success: function (response) {
// The shortened URL is response.shortenedURL
}
});
~ To use the URL just perform a GET request to urlq.herokuapp.com and the original URL will be redirected.
~ Example:
urlq.herokuapp.com/353 => this will get redirected to the original URL