https://colors-api.glitch.me
^ That’s my project.
app.get("/input/:color", (req, res) => {
var color = encodeURIComponent(req.params.color)
console.log(color)
//res.redirect(`/hex/${color}`)
})
If I sent a request to the url https://colors-api.glitch.me/input/#8adaff, I get “Cannot GET /INPUT”, but if I request to https://colors-api.glitch.me/input/8adaff, I get the right thing. I tried using encodeURIComponent, but it still doesn’t work. Any thoughts?
The hash ("#") is a part of the URL that doesn’t get sent to the server. You should replace # with a different character or not use it at all.
3 Likes
I see… I guess I’ll just write up some docs specifying that inputs can’t have # in them.
You can use # by url-encoding the input before adding it into the url, which you should do anyway for arbitrary input.
So for your example, https://colors-api.glitch.me/input/%238adaff
3 Likes
Hmmm - if I get it through a form, I might do that.
Thanks for offering some help!
2 Likes