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.
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024