This is a solution to the Shortly URL shortening API Challenge challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
Users should be able to:
- View the optimal layout for the site depending on their device's screen size
- Shorten any valid URL
- See a list of their shortened links, even after refreshing the browser
- Copy the shortened link to their clipboard in a single click
- Receive an error message when the
form
is submitted if:- The
input
field is empty
- The
- Solution URL: https://github.com/pavanmg007/URL-shortening-API-landing-page
- Live Site URL: https://pavanmg007.github.io/URL-shortening-API-landing-page/
- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- CSS Grid
- Mobile-first workflow
- React - JS library
- Tailwind CSS - For styles
I have learnt how useEffect Hook & Dependency Array works. Also go to know avout storing items in local storage in JSON
useEffect(() => {
localStorage.setItem("links", JSON.stringify(links));
}, [links]);
Ans also learnt how to parse local storage items .
const getLocalStorage = () => {
let links = localStorage.getItem("links");
if (links) {
return JSON.parse(localStorage.getItem("links"));
} else {
return [];
}
};
Learnt working with API Calls and handling the response.
const shortenLink = async () => {
const res = await fetch(`https://api.shrtco.de/v2/shorten?url=${text}`);
const data = await res.json();
setLinks([data.result, ...links]);
setText("");
};
shortenLink();
- Website - Github
- Frontend Mentor - @pavanmg007
- Twitter - @pavanmg007