I have no experience with JSON and yet I managed to do something about it.
I have the following code that works wonderfully thanks to the articles and forum searches I read:
import {fetch} from 'wix-fetch';
export function button31_click(event) {
let key = "https://api.rebrandly.com/v1/links/new?apikey=XXXXXXXXXXXXXXXXXX&domain[fullName]="
let domain = $w('#dropdown1').value;
let longUrl = $w('#input1').value;
let slashtag = $w('#input2').value;
let fullUrl = key + domain + '&destination=' + longUrl + '&slashtag=' + slashtag ;
fetch(fullUrl, {method: 'get'})
.then(response => response.json())
.then(json => $w("#text24").text = json.shortUrl);
}
my question is how can i add another value from the GET url?
like $w(“#text25”).text = json.slashtag) ?
and how can i add an error check?
(if error > do something)
i try this code but he doesn’t work:
import {fetch} from 'wix-fetch';
export function button31_click(event) {
let key = "https://api.rebrandly.com/v1/links/new?apikey=XXXXXXXXXXXXXXXXXX&domain[fullName]="
let domain = $w('#dropdown1').value;
let longUrl = $w('#input1').value;
let slashtag = $w('#input2').value;
let fullUrl = key + domain + '&destination=' + longUrl + '&slashtag=' + slashtag ;
fetch(fullUrl, {method: 'get'})
.then(response => response.json())
.then(json =>
$w("#text24").text = json.shortUrl
$w("#text25").text = json.slashtdg
);
.then( (json) => console.log(json.someKey) )