X Tutup
The Wayback Machine - https://web.archive.org/web/20200916142211/https://github.com/Keyang/node-csvtojson/issues/392
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First time using your library, example did not work for me #392

Open
doverradio opened this issue Jun 4, 2020 · 0 comments
Open

First time using your library, example did not work for me #392

doverradio opened this issue Jun 4, 2020 · 0 comments

Comments

@doverradio
Copy link

@doverradio doverradio commented Jun 4, 2020

Hello, I am trying to use your library but so far I didn't get the data from my test csv file and need help.
Below is my current code, for a single component that uses your library as a button, which, when clicked, supposed to trigger the use of csvtojson.

const csv = require('csvtojson');
const csvFilePath = '../test.csv';
import React, { Component } from 'react'
import { Button } from 'reactstrap';
// import fs from 'fs';

const getCsv = () => {
        csv()
        .fromFile(csvFilePath)
        .then((jsonObj)=>{
            console.log(jsonObj);
            return jsonObj
        
        })
    }
    
class Csvjson extends Component {


    
    render() {
      return (
        <Button onClick={getCsv}>Get CSV</Button>

      )
    }
  }


export default Csvjson

It is giving errors:
Error: Cannot find module 'fs'

But it's not clear how this occurred when I am not calling fs. So I left fs there commented but even when I uncomment it, it still gives same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.
X Tutup