I will leave the main issue here:
Code:
#!/usr/bin/node
import fetch from "node-fetch";
const privateKey = "PRIVATEKEY";
const runScript = async () => {
const allContent = await fetch(
"https://cdn.builder.io/api/v2/content/localizemodelexample?apiKey=32f148657e2646be8562eb4e6ebfa190&limit=1&fields=data.title,data.description"
).then((res) => res.json());
allContent.results.map(async (entry) => {
//grab the current image
console.log(entry);
const originalDefaultTitle = entry.data.title.Default;
const originalDefaultDescription = entry.data.description;
//update the entry to be localized
entry.data.title = {
"@type": "@builder.io/core:LocalizedValue",
Default: originalDefaultTitle,
en: originalDefaultTitle,
hu: originalDefaultTitle,
de: originalDefaultTitle,
sl: originalDefaultTitle,
cz: originalDefaultTitle,
};
entry.data.description = {
"@type": "@builder.io/core:LocalizedValue",
Default: originalDefaultDescription,
en: originalDefaultDescription,
hu: originalDefaultDescription,
de: originalDefaultDescription,
sl: originalDefaultDescription,
cz: originalDefaultDescription,
};
console.log(entry);
const result = await fetch(
"https://builder.io/api/v2/write/localizemodelexample",
{
method: "PATCH",
headers: {
Authorization: `Bearer ${privateKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify(entry),
}
)
.then(function (response) {
console.log(response);
return response;
})
.catch((e) => {
console.log(e);
});
});
};
runScript();
The get request:
https://cdn.builder.io/api/v2/content/localizemodelexample?apiKey=32f148657e2646be8562eb4e6ebfa190&limit=1&fields=data.title,data.description
{
"results":[
{
"data":{
"title":{
"Default":"test333"
},
"description":"<p><sub style=\"vertical-align: sub; font-size: smaller; color: rgb(255, 153, 0); background-color: rgb(0, 0, 0);\"><strong>Alma körte szia333333</strong></sub></p>"
}
}
]
}
And also turned on the localized value:
Here you can see the result. I don’t know why is it not working.
The result not visible in the visual editor:
Can you please help me to solve this problem?