Genie Discord forum
![Author Avatar](https://cdn.discordapp.com/avatars/340614394302169098/6cd1d4597124f232e695536b0a8d4bc8.png?size=512)
I have no idea what this means. It only happens when i'm in specific route, any ideas?
Error: 2023-11-20 19:29:13 ArgumentError: invalid base 10 digit 'P' in "Product 2"
Error: 2023-11-20 19:27:03 ArgumentError: invalid base 10 digit 'Н' in "НОЖНИЦЫ"
The thing is that data is still loaded from the database and passes into my templates, and it renders them. But it seems like no css is being loaded.
![Author Avatar](https://cdn.discordapp.com/avatars/743412727464067154/bc30abeb49653e9978c0f7c90f4486a8.png?size=512)
can you share your route definition? it looks like you've define the parameter as an integer but are passing a string instead
![Author Avatar](https://cdn.discordapp.com/avatars/340614394302169098/6cd1d4597124f232e695536b0a8d4bc8.png?size=512)
route("/products/:id") do
product_id = parse(Int64,payload(:id))
@info product_id
product_result = Products.get_product(product_id)
@info product_result
page = open(io->read(io, String),"./public/product.jl.html")
Html.html(page,product = product_result)
end
![Author Avatar](https://cdn.discordapp.com/avatars/340614394302169098/6cd1d4597124f232e695536b0a8d4bc8.png?size=512)
I specifically display this in console so that this could never happen
![Author Avatar](https://cdn.discordapp.com/avatars/340614394302169098/6cd1d4597124f232e695536b0a8d4bc8.png?size=512)
yet this does happen for some reason
![Author Avatar](https://cdn.discordapp.com/avatars/340614394302169098/6cd1d4597124f232e695536b0a8d4bc8.png?size=512)
okay i think i understood what you meant but i can't possibly know how id can become something else, given that i dont take it by id, but rather by a symbol
![Author Avatar](https://cdn.discordapp.com/avatars/340614394302169098/6cd1d4597124f232e695536b0a8d4bc8.png?size=512)
like not by 1 but by (:id)
![Author Avatar](https://cdn.discordapp.com/avatars/743412727464067154/bc30abeb49653e9978c0f7c90f4486a8.png?size=512)
in this line
product_id = parse(Int64,payload(:id))
payload(:id) will be whatever you have after /products/ in the URL. Hence, i it's not an integer then calling parse
throws an error
Try to display the value of id
in the REPL with @show
and you'll see why it's not working.
In case you've not seen it, we have a guide on building APIs
https://learn.genieframework.com/docs/guides/creating-an-api#api-endpoints
![Author Avatar](https://cdn.discordapp.com/avatars/340614394302169098/6cd1d4597124f232e695536b0a8d4bc8.png?size=512)
oh thanks
![Author Avatar](https://cdn.discordapp.com/avatars/340614394302169098/6cd1d4597124f232e695536b0a8d4bc8.png?size=512)
Well i'm trying to test this, yet i just can't find anything wrong with what i'm doing. Maybe this is a parse
error? Maybe you can't parse substrings?
![](https://cdn.discordapp.com/attachments/1176198522647871602/1177744060828635286/image.png?ex=65b43821&is=65a1c321&hm=38daf5a67ace37878481b2b4b20d4ef5f09b59f73b97766a66d95cc17d1054a3&)
![](https://cdn.discordapp.com/attachments/1176198522647871602/1177744061084479520/image.png?ex=65b43821&is=65a1c321&hm=0e1b41fd574aa21e1109cedc969fd5643661411231ba48ee273bf01ff264bd14&)
![Author Avatar](https://cdn.discordapp.com/avatars/743412727464067154/bc30abeb49653e9978c0f7c90f4486a8.png?size=512)
Why don't you set the type right in the URL like in the example I shared? That way an exception will be thrown if you pass anything other than an integer. This is the syntax:
route("/api/numbers/:N::Int", API.numbers)
![Author Avatar](https://cdn.discordapp.com/avatars/743412727464067154/bc30abeb49653e9978c0f7c90f4486a8.png?size=512)
By the way, we have more documentation on this
https://learn.genieframework.com/docs/reference/server/routing#matching-routes-by-type-of-arguments