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)
            }
        }
3
  • try this : stackoverflow.com/questions/44769051/… Commented Mar 17, 2022 at 3:21
  • Does this answer your question? How to upload and read CSV files in React.js? Commented Mar 17, 2022 at 3: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 Commented Mar 17, 2022 at 6:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.