1

I have used the shrtcode api and I dont know how to store its data.

var requestOptions = {
method: 'GET',
redirect: 'follow'
};
fetch("https://api.shrtco.de/v2/shorten?url=www.google.com", requestOptions)//api
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
 }
 Response
 ok true
 result 
 code             "fQdPc"
 short_link       "shrtco.de/fQdPc"
 full_short_link      "https://shrtco.de/fQdPc"
 short_link2          "9qr.de/fQdPc"
 full_short_link2  "https://9qr.de/fQdPc"
 short_link3          "shiny.link/fQdPc"
 full_short_link3  "https://shiny.link/fQdPc"
 share_link       "shrtco.de/share/fQdPc"
 full_share_link      "https://shrtco.de/share/fQdPc"
 original_link    "http://www.google.com"

How can I print or store the value of "full_short_link "?

1 Answer 1

1

Like this?

const doStuff = async () => {
    try {
        const res = await fetch('https://api.shrtco.de/v2/shorten?url=www.google.com');
        const json = await res.json();

        console.log('full_short_link', json.result.full_short_link);
    } catch (err) {
        console.error(err);
    }
};

doStuff();

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.