Hint: url shortner

there is hint for checking if url is valid or not but how do I shortern the url ?

hello there, this project requires you to create some sort of database where someone can store a url and in return receive a shortened url. i will give a brief example but using an object for data storageā€¦
const urlObj = {
url: req.body.url,
short_url: id
so you can store this object in your database, having received the url from form. The id can be generated in any way you feel but should be unique.
when someone now inputs the url to your project with the id as a parameter, it should search the database and find the object where short_url === id, if found it should get the original url of the same object as id and thus redirect to the actual url.

This is just a basic explanation of one way you could approach this challenge. I hope i have helped.

1 Like