2
<template>
  <div class="file-import">
    <file-pond
      name="files"
      credits=""
      label-idle="<span class='filepond--label-action'>file</span>"
      accepted-file-types="image/jpeg, image/png"
      :allow-multiple="true"
      server= "http://localhost:3000/upload"
      v-on:init="handleFilePondInit"
      >
    </file-pond>
    <button @click="printthis"> hi </button>

  </div>
</template>
<script>

setOptions({
  server: {
    url: 'http://localhost:3000/',
    process: {
      url: './upload',
      method: 'POST',
      withCredentials: false,
      timeout: 7000,
      onload: (response) => {
        //console.log(JSON.parse(response));
       
      },
      onerror: null
    },
  }
})

  data () {
    return {
      fileList: [],
    }
  },

I was trying to save response in setOptions into fileList. Yet, if I cannot find a way to do so. If I directly set fileList = response or fileList.push(response), the code does not recognize fileList in setOptions method. Is there a way to save response into fileList? Thank you in advance!

dlkhjs
  • 43
  • 4
  • You can't access vue component state outside of it. You can try moving your `setOptions` into one of the vue component lifecycle hooks functions. – capchuck Jul 30 '22 at 11:31
  • I have imported vueFilePond , {setOptions} from 'vue-filepond' and cannot use this method in vue component. Is there a way to move setOptions into vue component if this method has been imported? – dlkhjs Jul 30 '22 at 11:41
  • It's unclear to me what you're tryinh to do, but can't you just turn the whole thing into a vue component? Seems like it's begging for it. That way you could easily store your data, emit it to the parent and anything else you might want to do. – Dr4jw3r Jul 30 '22 at 12:12
  • Got it. Im just new to Vue so I was confused. It seems like if I use lifecycle hook, I can use imported function. Thanks – dlkhjs Jul 30 '22 at 13:21

0 Answers0