App reviews, troubleshooting, and recommendations
I find that it is possible to call the shopify api on extension directly. The doc is available on this link: Admin UI extensions. According to the documentation, API calls from extension are automatically autenticated by default.
However, I can't get it to work properly. I get this erro when I use fetch to get data from shopify api
The code of my extension file "star_rating.liquid":
<script>
fetch('shopify:admin/api/graphql.json', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: `
query {
products(first: 10) {
edges {
node {
id
title
handle
}
cursor
}
pageInfo {
hasNextPage
}
}
}
`
}),
}).then(resp => resp.json()).then(body => {
console.log(body)
});
</script>
<div style="background-color: blue; width: 400px; height: 400px; text-align: center">
<p style="color: white">teste</p>
</div>
{% schema %}
{
"name": "Star Rating",
"target": "section",
"settings": [
{ "type": "product", "id": "product", "label": "product", "autofill": true },
{ "type": "color", "id": "colour", "label": "Star Colour", "default": "#ff0000" }
]
}
{% endschema %}
@Samirjs Hi, I hope you are doing well..
It seems that the issue you’re facing might be due to an error in the extension code. One thing I noticed is that the schema in your code doesn’t seem to align with the documentation for Admin UI extensions. Additionally, it looks like you might be working on a Theme App Extension.
To address the issue, you may need to update the code to match the documentation standards. If the problem persists, I’d suggest sharing more details or the relevant code snippet here. That way, I or another community member can assist you more effectively.
Hope this helps! 😊
Yes. You are right. I'm using Theme App Extension and the documentation is for Admin UI Extension. So isn't there a way to make a direct api request on Theme App Extension? I'm trying to make requests to shopify api on an extension-only app.
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025