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

Closed
doverradio opened this issue Jun 4, 2020 · 1 comment
Closed

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

doverradio opened this issue Jun 4, 2020 · 1 comment

Comments

@doverradio
Copy link

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.

@flymans
Copy link

flymans commented Dec 2, 2020

fs module is supported by nodejs, not raw JS

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

No branches or pull requests

2 participants