vue-json-excel icon indicating copy to clipboard operation
vue-json-excel copied to clipboard

[Vue warn]: Invalid prop: type check failed for prop "fetch". Expected Function, got Promise

Open izhoubin opened this issue 4 years ago • 4 comments

<template>
  <div id="app">
    <h2>Fetch Example</h2>
    <downloadexcel
      class = "btn"
      :fetch   = "fetchData(arguments)"
      :fields = "json_fields"
      :before-generate = "startDownload"
      :before-finish = "finishDownload"
      type    = "csv">
      Download Excel
    </downloadexcel>
  </div>
</template>

i need to add aguments in fetchData method,but if i do this,error happens.

[Vue warn]: Invalid prop: type check failed for prop "fetch". Expected Function, got Promise

izhoubin avatar Aug 15 '19 03:08 izhoubin

Have you solved the issue? I have a similar issue. In callback I dispatch vuex action. It means I have a promise in my function. It seems that fetch function is executed continuously and return same error you get.

albertovincenzi avatar Sep 09 '20 14:09 albertovincenzi

@albertovincenzi I think the problem is that the fetch prop is type function... It will be excuted asynchronously, but the type check fails and never get call. I'm updating this component this week, I let you know if I come across any solution.

jecovier avatar Oct 05 '20 04:10 jecovier

I had the same error, but it is working now. If you have to pass argument to fetch callback, call like this

:fetch= "()=>{return getInvoices(props.item.user.id)}"

Mani1124 avatar Oct 27 '20 23:10 Mani1124

@Mani1124 oh I see! that's a really good solution... I'm going to test this over the weekend, if everything goes well I'll update the documentation... Thanks!

jecovier avatar Oct 29 '20 11:10 jecovier