2

i have a url which onclick downloads me a csv file.I want to fetch data from that url and show it in console.How can i do it?

 const downloadCsv = async () => {
            try {
                const target = `https://connect.emgsrv.com/wT3Kjzu4B3P43VQikYjq/wT3Kjzu4B3P43VQikYjq.CSV`; //file

                
                const res = await fetch(target, {
                    method: 'get',
                     mode: 'no-cors',

                    
                    headers: {
                        'content-type': 'text/csv;charset=UTF-8',
                        //'Authorization': //in case you need authorisation
                    }
                });
        
             
        
                    const data = await res.text();
                    console.log(data,'hahah');
        
                
            } catch (err) {
                console.log(err)
            }
        }
  • try this : https://stackoverflow.com/questions/44769051/how-to-upload-and-read-csv-files-in-react-js – tsamridh86 Mar 17 '22 at 03:21
  • Does this answer your question? [How to upload and read CSV files in React.js?](https://stackoverflow.com/questions/44769051/how-to-upload-and-read-csv-files-in-react-js) – tsamridh86 Mar 17 '22 at 03:21
  • i want to show the data in my console that i will get from url when page loads i will fetch that url and i need to get those data inside the url @tsamridh86 Can you look into my code and get the idea – Sirjan Baral Mar 17 '22 at 06:02

0 Answers0