manasa

manasa

  • NA
  • 4
  • 438

How to change this result into json array format? now is in objectform

Feb 9 2023 10:09 AM

app.get("/Products", (req,res)=>{

    sql.connect (db,function(err){

        if(err)console.log(err);

        const request=new sql.Request();

        request.input("portfolioId",sql.Int,req.body.portfolioId);

        request.execute("GetAllProductList",(function(err, result){

           console.dir(result);

           res.json(result)

            console.dir(err);

          }))

output:

{
  recordsets: [
    [
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object]
    ]
  ],
  recordset: [
    { ProductName: 'AdminCentre (Elvis - PBX)' },
    { ProductName: 'CloudLink Gateway for SMBC' },
    { ProductName: 'Mi Cloud Connect' },
    { ProductName: 'MiCloud Connect' },
    { ProductName: 'MiCloud Flex' },
    { ProductName: 'MiCloudConnect' },
    { ProductName: 'Mitel Communications Director' },
    { ProductName: 'Mitel Standard Linux' },
    { ProductName: 'Mitel Virtualization Framework' },
    { ProductName: 'MiVoice 5000' },
    { ProductName: 'MiVoice 5000 Manager' },
    { ProductName: 'MiVoice Business' },
    { ProductName: 'MiVoice Business Express' },
    { ProductName: 'MiVoice Business for Multi-Instance' },
    { ProductName: 'MiVoice Business Multi-Instance' },
    { ProductName: 'MiVoice Connect' },
    { ProductName: 'MiVoice Connect Contact Center' },
    { ProductName: 'MiVoice MX-ONE' },
    { ProductName: 'MiVoice Office 250' },
    { ProductName: 'MiVoice Office 400' },
    { ProductName: 'ShoreTel' },
    { ProductName: 'SX-200 ICP' },
    { ProductName: 'Telepo' }
  ],
  output: {},
  rowsAffected: [],
  returnValue: 0
}

please help me how to remove this recordset,returnvalue , i want only  data in this format [{productname:'telco'}]


Answers (1)