Skip to content

SQLx query in handler #2113

Closed Answered by iblacksand
ruizdiazever asked this question in Q&A
Jul 21, 2023 · 3 comments · 4 replies
Discussion options

You must be logged in to vote

I may be mistaken, but I believe the error is because of the order of the parameters of insert_test_metrics. I very similar error message, and it was because the Json payload parameter always has to be the last argument. For example, instead of

pub async fn insert_test_metrics(
    axum::Json(metric): axum::Json<Metric>,
    pool: extract::Extension<PgPool>
    ) -> Result<axum::Json<Metric>, axum::Error>  {

it should be

pub async fn insert_test_metrics(
    pool: extract::Extension<PgPool>,
    axum::Json(metric): axum::Json<Metric>
    ) -> Result<axum::Json<Metric>, axum::Error>  {

In the fixed example, the Json parameter is removed completely, so I think this solved the error you saw,…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@ruizdiazever
Comment options

@davidpdrsn
Comment options

@ruizdiazever
Comment options

@iblacksand
Comment options

Answer selected by jplatte
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #2112 on July 21, 2023 10:16.