1 / 4

json2CSV in POST data using Node.js and Angular.js

You must have tried with downloading data in CSV using GET request from UI and used Node.js as backend.<br><br>How are you going to download the same data in csv using POST request from UI ? ( thereu2019s some scenario where you need to consume some data from UI and rest from backend code )<br><br>Topics covered:<br><br>1. Download CSV using GET request using node.js NPM<br><br>2. Download CSV using POST request<br><br>Download CSV using GET request<br><br>json2csv<br><br>If you are using Hapi.js Framework<br><br><br>json2csv = require('json2csv');<br><br>json2csv({data: request.payload, <br> fields: ['productId', 'extProductId', 'tenantId', <br>

Télécharger la présentation

json2CSV in POST data using Node.js and Angular.js

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. AUG 2023 08 Asign menu 0   HOME INSIGHTS ABOUT US WEB PORTFOLIO MOBILE PORTFOLIO CAREERS CONTACT US BLOG Blog Home / Web Design and UI design / json2CSV in POST data using Node.js and Angular.js ANGU L AR. JS DEVEL OPM ENT SERVI CES, CU ST OM SOFT W ARE DEVEL OPM ENT COM PANY I N BANGAL ORE, M OBI L E APPL I CAT I ONS DEVEL OPM ENT , NODE JS - BACK END, NODE. JS, W EB DESI GN AND U I DESI GN json2CSV in POST data using Node.js and Angular.js   CronJ, 8 years ago 1 min read ? Listen to Post You must have tried with downloading data in CSV using GET request from UI and used Node.js as backend. How are you going to download the same data in csv using POST request from UI ? ( there’s some scenario where you need to consume some data from UI and rest from backend code ) Topics covered: 1. Download CSV using GET request using node.js NPM 2. Download CSV using POST request Download CSV using GET request

  2. If you are using Hapi.js Framework json2csv = require('json2csv'); json2csv({data: request.payload, fields: ['productId', 'extProductId', 'tenantId', 'supplierId', 'statusId', 'mfgProductId', 'mfgProductName', 'manufacturerId', 'manufacturerName'], fieldNames: ['productId', 'extProductId', 'tenantId', 'supplierId', 'statusId', 'mfgProductId', 'mfgProductName', 'manufacturerId', 'manufacturerName']}, function(err, csv) { if (err) console.log(err); return reply(csv) .header('Content-Type', 'application/octet-stream') .header('content-disposition','attachment; filename=CronjReport.csv;'); }); If you are using Express.js Framework json2csv = require('json2csv'); json2csv({data: request.payload, fields: ['productId', 'extProductId', 'tenantId', 'supplierId', 'statusId', 'mfgProductId', 'mfgProductName', 'manufacturerId', 'manufacturerName'], fieldNames: ['productId', 'extProductId', 'tenantId', 'supplierId', 'statusId', 'mfgProductId', 'mfgProductName', 'manufacturerId', 'manufacturerName']}, function(err, csv) { if (err) console.log(err); response.setHeader('Content-Type', 'application/octet-stream'); response.setHeader("Content-Disposition", 'attachment; filename=CronjReport.csv;'); response.end(csv, 'binary'); });

  3. Download CSV using POST request You only need to handle di?erently from Angular side. $http.post('/exportProduct',searchdata) .success(function(data, status, headers, config) { var element = angular.element(''); element.attr({ href: 'data:attachment/csv;charset=utf-8,' + encodeURI(data), target: '_blank', download: 'name.csv' })[0].click(); }) .error(function(data, status, headers, config) { }); VIA SOURCE TAGS #ANGULAR.JS #CRONJ #EXPRESS.JS #HAPI.JS #HYDERABAD #NODE JS ANGU L AR. JS DEVEL OPM ENT SERVI CES, NODE JS - BACK   U NCAT EGORI ZED END, NODE. JS, W EB DESI GN AND U I DESI GN Hapi ?le upload download Frameworks are a developers best friend. CronJ CronJ is a product development company which solves problems in Video analytics, IoT, Industrial automation, Manufacturing 4.0, Smart Factory, Smart City, Blockchain, Arti?cial Intelligence, Mobility Solutions and supply chain consulting. Related posts

  4. WordPress Theme built by Shu?ehound.

More Related