Basierend auf this Tutorial, habe ich den folgenden Code versucht. Ich versuche, der Webseite ein neues Skript hinzuzufügen.Erstellen Sie ein neues Skript-Tag (Shopify) Fehler: Ungültige URI "/"
request.post(accessTokenRequestUrl, {
json: accessTokenPayload
})
.then((accessTokenResponse) => {
const accessToken = accessTokenResponse.access_token;
// DONE: Use access token to make API call to 'shop' endpoint
const shopRequestUrl = 'https://' + shop + '/admin/shop.json';
const shopRequestHeaders = {
'X-Shopify-Access-Token': accessToken,
'Content-Type': 'application/json'
};
const createScriptTagUrl = 'https://' + shop + '/admin/script_tags.json';
const scriptTagBody = {
"script_tag": {
"event": "onload",
"src": "https:\/\/djavaskripped.org\/fancy.js"
}
}
request.get(shopRequestUrl, {
headers: shopRequestHeaders
})
.then((shopResponse) => {
res.status(200).end(shopResponse);
})
.catch((error) => {
res.status(error.statusCode).send(error.error.error_description);
});
request.post(createScriptTagUrl, {
json: scriptTagBody
}, {
headers: shopRequestHeaders
})
.then((scriptResponse) => {
res.status(200).end(scriptResponse);
})
.catch((error) => {
res.status(error.statusCode).send(error.error.error_description);
});
Allerdings bekomme ich RequestError: Error: Invalid URI "/"
Bin ich etwas fehlt? Oder hat der Src-Wert ein Problem?
ich mit 'request.post versucht (createScriptTagUrl, {json: scriptTagBody}, {Header: shopRequestHeaders})' jedoch weiterhin besteht das Problem weiterhin. Mit oder ohne \ –