feat: Modification du design
This commit is contained in:
@ -47,12 +47,27 @@ async function fetchData() {
|
||||
const url = `/items/scores?${fields
|
||||
.map((item) => `fields[]=${item}`)
|
||||
.join("&")}`;
|
||||
const data = (await fetchJSONApi(url)).data;
|
||||
await fs.writeFile("./src/data.json", JSON.stringify(data), "utf8");
|
||||
const scores = (await fetchJSONApi(url)).data;
|
||||
await fs.writeFile("./src/data.json", JSON.stringify(scores), "utf8");
|
||||
|
||||
const folder = "public/answers";
|
||||
if (!existsSync(folder)) mkdirSync(folder);
|
||||
for (const score of data) {
|
||||
for (const score of scores) {
|
||||
const uuid_score = score.image;
|
||||
if (uuid_score) {
|
||||
console.log(`Score image : ${folder}/${uuid_score}`);
|
||||
const response = await fetchAsset(uuid_score);
|
||||
try {
|
||||
const thumbnail = sharp().resize({ height: 200 }).webp();
|
||||
await streamPipeline(
|
||||
response.body,
|
||||
thumbnail,
|
||||
createWriteStream(`${folder}/${uuid_score}.webp`)
|
||||
);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
for (const question of score.questions) {
|
||||
for (const answer of question.questions_id.answers) {
|
||||
const uuid = answer.answers_id.image;
|
||||
|
Reference in New Issue
Block a user