Response Not found, status 404

27 views
Skip to first unread message

Carlos Henrique

unread,
Sep 11, 2017, 2:19:55 PM9/11/17
to tedious
Hey, guys.

Can someone help me?

I want to return a value. I used the Get method, to pick up some info.
But the postman, says Not found, status 404


import Fs from 'fs'
import Path from 'path'
import Mime from 'mime'


import { Connection } from 'tedious'  
import { Request } from 'tedious'  
const TYPES = require('tedious').TYPES


module.exports = async (ctx, next) => {


var config = {
    userName
: process.env.DB_USER,
    password
: process.env.DB_PASS,
    server
:  process.env.DB_HOST,


    options
: {


       database
: process.env.DB_BASE ,
       rowCollectionOnRequestCompletion
: true
     
}
 
}


const connection = new Connection(config)


let rowdata
= {}
let rowarray
= []
 
  connection
.on('connect', (err) => {
     
if (err) {
          console
.log(`error : ${err}`)
     
} else {
         let sql
= `select a.nome as name, CONVERT(varchar(7),r.date, 126) as date
                       from blah a left join  blah r
                                 on a.blah = r.blah
                               where a.blah = @blah `



          let request
= new Request(sql, function(err, rowCount) {
               
if (err) {
                  console
.log(err);
               
} else {
                  ctx
.statusCode = 200
                  ctx
.body = JSON.stringify(rowdata)
                  console
.log(rowdata.name)
               
}
             
})


           request
.addParameter('blah ', TYPES.Int, ctx.params.id)


            request
.on('row', function(columns) {
           
              columns
.forEach(function(column) {
                   rowdata
[column.metadata.colName] = column.value
                  console
.log(column.value)
                  console
.log(column.metadata.colName)              
             
})
             rowarray
.push(rowdata)
           
})
           
            connection
.execSql(request);
     
}
 
})
}






Reply all
Reply to author
Forward
0 new messages