More refactoring and porting to React

This commit is contained in:
Colin McLeod
2015-12-13 11:51:58 -08:00
parent 035f6b3efa
commit ab0019424f
58 changed files with 2243 additions and 2507 deletions

View File

@@ -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');
}
}