print the price for each year
This commit is contained in:
parent
e69e3e0789
commit
cf0f4e7568
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
.env
|
||||
.vscode/
|
12
api.ts
12
api.ts
@ -1,12 +1,10 @@
|
||||
import { Application, Router } from 'https://deno.land/x/oak/mod.ts';
|
||||
import { Client } from "https://deno.land/x/postgres@v0.17.0/mod.ts";
|
||||
import { load } from "https://deno.land/std/dotenv/mod.ts";
|
||||
|
||||
const app = new Application();
|
||||
const router = new Router();
|
||||
|
||||
//---------dotenv info-------------
|
||||
import { load } from "https://deno.land/std/dotenv/mod.ts";
|
||||
|
||||
const env = await load();
|
||||
const hostname = env["HOSTNAME"];
|
||||
const port = env["PORT"];
|
||||
@ -15,7 +13,6 @@ const password = env["PASSWORD"];
|
||||
const database = env["DATABASE"];
|
||||
const app_port = env["APP_PORT"];
|
||||
|
||||
|
||||
// Configure database connection
|
||||
const client = new Client({
|
||||
hostname:hostname
|
||||
@ -41,6 +38,13 @@ router.get('/price_info/part_cust/:partcode/:customer', async (ctx) => {
|
||||
|
||||
const result = await client.queryObject({args: [partcode, customer], text: query} );
|
||||
|
||||
for (const row of result.rows) {
|
||||
if (typeof row.season === 'object' && row.season !== null) {
|
||||
for (const year in row.season) {
|
||||
console.log(row.season[year].price_usd)
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
app.use(router.routes());
|
||||
|
Loading…
Reference in New Issue
Block a user