Hello Campers, im right at the start of the Api Shortener Project, im having some issues with the POST method in the index.html
So lets say i have this Form that is sent to "api/shorturl/new as a POST method
<form action="api/shorturl/new" method="POST">
<label for="url_input">URL to be shortened</label>
<input id="url" type="text" name="url" value="https://www.freecodecamp.org">
<input type="submit" value="POST URL">
</form>
Later on my server.js i catch this submit with
app.post("/api/shorturl/new",(req, res) => {
var url=req.body.url;
});
and i need that url to be passed to the get method so i can check if this is a valid url
app.get("/api/shorturl/new/:url(*)", function(req, res) {
var url = req.params.url;
if (validUrl.isUri(url)){
console.log('Looks like an URI');
} else {
console.log('Not a URI');
}
});
i think my question whould be. How can i redirect a the submit data to the appget and have them linked ?