Kyon147 / laravel-shopify

A full-featured Laravel package for aiding in Shopify App development
MIT License
353 stars 102 forks source link

Call to a member function api() on null #172

Closed Haroune213 closed 1 year ago

Haroune213 commented 1 year ago

Hello, I am trying to call the shopify rest api but I am getting this error.

This is the part of my code that is getting an error:

 $shop=Auth::User();
 $themes= $shop->api()->rest('GET','admin/themes.json');

In my terminal I am getting this error: Undefined method 'api'.

When I am trying to run the app on localhost I am getting this error: Call to a member function api() on null

ggelashvili commented 1 year ago

Are you working with SPA? User may not be logged in for non ajax requests if you are sending the session token from your front-end for example. I would try to debug & see at which point the user is set & authenticated.

Kyon147 commented 1 year ago

@Haroune213 it depends on how you are logging into the app, do your routes have the middleware on them?

It looks like you are trying to access api() on a Auth but not user is logged in.

Closing as this is not a package issue, please ask for help in Discussions or on the Discord.