jecovier / vue-json-excel

MIT License
687 stars 168 forks source link

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

Open izhoubin opened 5 years ago

izhoubin commented 5 years ago
<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

albertovincenzi commented 4 years ago

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.

jecovier commented 4 years ago

@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.

Mani1124 commented 3 years ago

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)}"

jecovier commented 3 years ago

@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!