-3

Website is built using node js/express, and unable to generate an URL to download the data from mysql table to a csv file. Is it possible to do without php?

ideally:

"a href="data.csv" target="_blank">Download Data"

"some type of code"

(for some reason the code isn't copying over...)

Dd6718
  • 5
  • 3
  • 1
    This is an “I want a pony” question which makes it too broad and outside the focus of Stack Overflow. If you make an attempt and show us your code we can understand what you’re trying to do on a technical level. Even a small amount of code, however incomplete, can help with showing context and intentions. If you really don't know where to start and need guidance or support consider mentoring and coaching services like [Codementor](https://www.codementor.io), [Savvy](https://www.savvy.is), [Hackhands](https://hackhands.com), or [airpair](https://www.airpair.com). – tadman Dec 20 '18 at 20:48
  • Yes, you can do in Node.js what you can do in PHP and vice-versa. – tadman Dec 20 '18 at 20:48

1 Answers1

-2

Learning approach: - First, create some "mock" CSV, save it somewhere on server and use this: Download a file from NodeJS Server using Express Assure that you properly download it.

  • After that, use this: Write to a CSV in Node.js With this one, you can find out how to make CSV from any data.

  • Make now, that you prepare your data from SQL and really save .csv file on server (second link) and then create its download (first link). Assure that this properly work.

Now, you have solution which works what you need, but it is not nice, it has extra step (saving file to server to download it). Check this: Express - Return binary data from distant webservice

Here it is described how can you download "binary data".

So, your final algorithm should be: - Make SQL queries, prepare CSV data - Get that CSV data as "binary" - Perform download through express, of that binary data

emir-alicic
  • 97
  • 1
  • 5