alecritson / Placid-Statamic

Consume REST services in your templates
MIT License
54 stars 1 forks source link

[v2] PlacidTags does not have a method 'index' #23

Closed bzerangue closed 4 years ago

bzerangue commented 4 years ago

Alec,

Thank you for the wonderful Placid v2 plugin for Statamic version 2.

I am using the 2.0.4 of the Placid plugin on Statamic 2.11.16.

I am getting the following error on a new installation of Statamic 2.11.16

ErrorException in Engine.php line 163: call_user_func() expects parameter 1 to be a valid callback, class 'Statamic\Addons\Placid\PlacidTags' does not have a method 'index'

I have tried both ways...

using the saved request, resources/placid/requests/placeholder.yaml

{{ placid handle="placeholder" }}
  {{ response.data }}
    <h1>{{ title }}</h1>
  {{ /response.data }}
{{ /placid }}

and full request

{{ placid host="https://jsonplaceholder.typicode.com" path=":part/:id" cache="60" query="foo:bar|bar:baz" segments="part:posts|id:1" headers="foo:bar" }}
  {{ response.data }}
    <h1>{{ title }}</h1>
  {{ /response.data }}
{{ /placid }}

Both give met the same error (that I list above)

Any thoughts on how to fix this?

Unfortunately, I can't use Statamic v3 yet. Since I need to do a production site on v2 since it is stable.

alecritson commented 4 years ago

Hi @bzerangue

Try

{{ placid:request handle="placeholder" }}
  {{ response.data }}
    <h1>{{ title }}</h1>
  {{ /response.data }}
{{ /placid:request }}

I'll try and get the index method added so it's a bit nicer. Thanks for reporting this.

bzerangue commented 4 years ago

That worked. Thank you! Actually, I noticed the documentation on your README is what I needed. I was focusing on the documentation on the Statamic Marketplace which was giving me the error.

https://statamic.com/marketplace/addons/placid