Home>

Vux environment is built with Nuxt.js.
When I put a value in the input field and press the button, I want to write it as json data and write it to a file.
The error "fs.writeFileSync is not a function" appears and the file cannot be exported.

# pages/index.vue
<template>
  
    <form action = "/ thanks" method = "post">
      <section>
         (1) Enter your name. 
        <input v-model = "yourName" type = "text">
      </section>
      <section>
         (2) Enter the message. 
        <textarea v-model = "yourMessage" />
      </section>
      <input type = "submit" value = "send" @ click = "exportMessage">
    </form>
  
</template>
<script>
export default {
  data () {
    return {
      yourName: '',
      yourMessage: ''
    }
  },
  methods: {
    exportMessage () {
      const fs = require ('fs')
      const data = {
        yourName: this.yourName,
        yourMessage: this.yourMessage
      }
      fs.writeFileSync ('test.json', JSON.stringify (data))
    }
  }
}
</script>


The code is currently in the above state.
When you use "fs.writeFileSync", you shouldn't write inmethod, but I don't know how to do it.