How to pass a url as a parameter? [Solved]

How to pass a url as a parameter? [Solved]
0

#1

Hi, every one. I stuck in URL Shortener Microservice challenge. I dont know how to pass a url as a parameter in project.

Ex: i type my-app.com/https://google.com and it response: cannot GET /https://google.com

thanks all.


#2

What have you tried?

Are you aware of the syntax for parsing parameters from URLs in Express?

http://expressjs.com/en/api.html#req.params


#3

You can use a wild ward to solve this issue :

var app = require('express')();

app.get("/*", function(req, res) {
    
    var url = req.params[0];
    console.log(url); // http://www.google.com

});

app.listen(3000);


#4

Thank you guys i solved this problems :smiley:


#5

Thank you so much! I’m working on my project and this helped me tremendously! :slight_smile:


#6

@Omegga
Please can you help with this.