Getting 422 Unprocessable Conte
I am getting this error while fetching data from a model through POS UI extensions heres the code
const [{ data, fetching, error: queryError }] = useFindMany(
api.buyBackProduct,
{
pause: !ready,
}
);

53 Replies
How can i changed the request url to a different environment
Where you instantiate the client, you need to set the environment arguement. Have a look at these docs: https://docs.gadget.dev/api/example-app/development/external-api-calls/installing#connecting-to-a-specific-environment
Installing - example-app Docs - Gadget
Gadget Docs
For example:
Actually this is set right as when i fetch it through app it return OK.
But when i use Extensions to fetch data it gives me the above error

Why its not working through extensions

Could you please show me how you instantiate in the extension? Please note that the extension doesn't have access to the current node_env
I just used this in a custom hook
import { useApi } from "@shopify/ui-extensions-react/point-of-sale";
import { useFindMany } from "@gadgetinc/react";
Not sure where to initilize it
Whats the name of your application?
True, I could have taken it from the image
Is this code from another extension or is it the theme app extension? If it's the theme app extension, React hooks and typical API calls won't work
Its POS UI extension
Sorry, I should have been more clear. The extension you're working on doesn't seem to be in the application so I can't quickly look at the code and tell you whats wrong
Oh let me push
Please check now
Sidenote, you don't need to add these packages to your extension package.json:

Looks like this is your issue:

I don't think that isDevStore is ever set
So you default to production
Yeah that was the case
But now getting this
GGT_INVALID_SHOPIFY_SESSION_TOKEN: Invalid Shopify Session Token passed in Authorization header, token could not be decoded"
What dev store are you testing on?
And should you be testing on the development env or
ahmad-dev
In your case you would probably want this:
Ahmed-dev
And the store you're working on? Is it
roadmap-ahmad.myshopify.com
?
Thats the only store that you have your application installed on, on your envYes
Working on that store
Now getting this. Is it due to entry wasnt found?

And is the request method correct? I am using the useFindMany hook
Are you seeing any errors in the console or just in the network tab?
Console as well

Should i use routes to fetch instead if possible? Whats the recommended approach here?
I think that this is happening cause of something else
Like?
Digging now
Can I move some stuff around?
Sure
Test that and see what you get
On it
Getting this now

Ok so I fixed the auth issues by changing the way that you set up the provider

Thats why your current issue is happening

Yeah
Let me change something
Ok
Try it now
The error might have actually hidden any other errors. We'll see
Is everything working as expected?

Ok so I see a 401 there
I feel like we're missing something
LEt me tak a look at your backend logs
Sure
What store is the extension running on right now? You might have selected the incorrect one when initializing shopify app dev. I'm just curious
Interesting that I see a 530 error though
• Dev store: roadmap-ahmad.myshopify.com
The store is right
Did you find anything?
Still digging
It worked
Did you change something?
I changed the environment to ahmed-dev with your new code
const api = new Client({
environment: "ahmad-dev",
});
Thanks so much!
For all the help!
No problem!