Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
PostgresError about statement syntax in postman using deno-postgres

Creating a deno app http server from a crash course, with Oak and deno-postgres modules , i'm trying to add some data to postgre, everything works fine until send data to database. I get 500 interval server error in Postman :

Json response in Postman after post request:

{
    "success": false,
    "msg": "PostgresError: syntax error at or near 'table'"
}

my code :

import { Client } from "https://deno.land/x/postgres@v0.14.3/mod.ts";
import { dbCreds } from '../config.ts'
//deno run --allow-net --allow-read --allow-env server.ts
// Init client
const client = new Client(dbCreds)

const addProduct = async ({ request, response }: { request: any, response: any }) => {    
    const body = await request.body()
    const product = body.value 

    if (!request.hasBody) {
        response.status = 400
        response.body = {
            success: false,
            msg: 'No data'
        }
    } else {
        try {
            await client.connect()

            const result = await client.queryObject("INSERT INTO table (name,description,price) VALUES ($1,$2,$3);", 
            product.name,
            product.description,
            product.price)

            response.status = 201
            response.body = {
                success: true,
                data: product
            }
        } catch (err) {
            response.status = 500
            response.body = {
                success: false,
                msg: err.toString()
            }
        } finally {
            await client.end()
        }
    }
}

Is it the right syntax to insert data with deno-postgres?

I'm using postgres@v0.14.3 and oak (https://deno.land/x/oak/mod.ts)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!