$.getJSON('http://api.bit.ly/v3/shorten?login=myusername&apiKey=myapi&longUrl=http://google.com', function (response) {
console.log('short_url');
e = response.data.hash;
bit.ly api can't define the hash JavaScript [closed]
-
03-08-2022 - |
Question
im trying to define some variable with the hash of my short link, using bit.ly api:
$['getJSON']('http://api.bit.ly/v3/shorten?login=myusername&apiKey=myapi&longUrl=http://google.com', function (shortlink) {
console['log']('short_url');
e = _shortlink['hash'];
i'm trying to define the "e" variable as the hash of the link. I mean the result of the link is:
{ "status_code": 200, "status_txt": "OK", "data": { "long_url": "http:\/\/google.com\/", "url": "http:\/\/bit.ly\/blabla", "hash": "XXXXX", "global_hash": "YYYYY", "new_hash": 0 } }
as u can see, I need not only to "GET" the "hash" variable, I also need to dig into the "data" result and only then get from it the hash.
I want that my "e" variable will be in the end of the day
e = XXXXXX
what should I do?
thanks alot!
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow