问题描述
我正在为 shopify 开发一个心愿单应用程序,并且自最近两天以来就遇到了这个问题。
Server.js
fetch(`https://${shop}/admin/api/2021-01/script_tags.json`,{
method: 'POST',headers: {
'Content-Type': 'application/json',"X-Shopify-Access-Token": accesstoken,},body: JSON.stringify({"script_tag": {
"event": "onload","src": `https://7902667a34dd.ngrok.io/script.js`,"display_scope": "all"
}})
}).then(async response => {
const data = await response.json();
// check for error response
try{
if (response.ok) {
// get error message from body or default to response status
// const error = (data && data.message) || response.status;
// return Promise.reject(error);
console.log(`no errorr!!!`);
}
}
catch(error){
this.setState({ errorMessage: error.toString() }).bind(this);
console.error('There was an error!',error);
}
});
使用此发布请求成功创建脚本标签。
让我知道在哪里添加 script.js 文件。我已经按照 shopify 教程 https://shopify.dev/tutorials/build-a-shopify-app-with-node-and-react/embed-your-app-in-shopify 在本教程中一切正常。
您的帮助将不胜感激。谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)