0

EX: const jsonData = [{ age: 12, name: 'Someone' }]; And i want convert jsonData to file JSON and use this file to send request to the S3 sever.

2 Answers 2

0

I don't think you can do something like that, I believe writing to file using react is not quite straight forward refer: this

Refer node solution here

Well, what do you mean 'use this file to send request'? Do you want to store the created JSON file in S3? then pls do it in the backend.

Sign up to request clarification or add additional context in comments.

Comments

0

Ok... the S3 thing is a big complicated for such a short question, but in general you can do something like this...

fs.writeFile("../../pathToFile.json", yourJSON, 'utf8', (err) => {
    if (err) {
        console.log("Ahh mother****");
        return console.log(err);
    }
    console.log("Now I have to send it to S3");
});

1 Comment

I have an error when using fs " fs.writefile is not a function" and I use browserify-fs but it have the same error.

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.