mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-10 07:05:35 +00:00
More refactoring and porting to React
This commit is contained in:
@@ -2,9 +2,15 @@ import request from 'superagent';
|
||||
|
||||
const SHORTEN_API = 'https://www.googleapis.com/urlshortener/v1/url?key=';
|
||||
|
||||
/**
|
||||
* Shorten a URL using Google's URL shortener API
|
||||
* @param {string} url The URL to shorten
|
||||
* @param {function} success Success callback
|
||||
* @param {function} error Failure/Error callback
|
||||
*/
|
||||
export default function shortenUrl(url, success, error) {
|
||||
if (window.navigator.onLine) {
|
||||
request.post(SHORTEN_API + GAPI_KEY)
|
||||
request.post(SHORTEN_API + window.CORIOLIS_GAPI_KEY)
|
||||
.send({ longUrl: url })
|
||||
.end(function(err, response) {
|
||||
if (err) {
|
||||
@@ -14,6 +20,6 @@ export default function shortenUrl(url, success, error) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return error('Not Online');
|
||||
error('Not Online');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user