From e390b9568e4c420923dc3d5fe332c12c64e34939 Mon Sep 17 00:00:00 2001 From: "gwenael.planchon" Date: Wed, 27 Mar 2024 17:50:45 +0100 Subject: [PATCH] ajouter difficulte.js --- science-quest/src/data/difficulte.js | 57 ++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 science-quest/src/data/difficulte.js diff --git a/science-quest/src/data/difficulte.js b/science-quest/src/data/difficulte.js new file mode 100644 index 0000000..0e4cb9c --- /dev/null +++ b/science-quest/src/data/difficulte.js @@ -0,0 +1,57 @@ +import { REST_API } from "@/assets/const" +import { DataObject, PagedDataObject } from "./dataObject" + +export class Difficulte extends DataObject{ + constructor(parsedJSON){ + super(parsedJSON) + } +} + +export class Difficultes extends PagedDataObject{ + constructor(parsedJSON){ + super(parsedJSON, Difficulte) + } + static async getPage(pageNb=0, size=0){ + let params="" + if(size>0){ + params+=`&size=${size}` + } + const response = await fetch(`${REST_API}/Difficultes?page=${pageNb}${params}`) + return new this(await response.json()) + } +} + + + +/* JSON de reference (Difficultes) +{ + "_links" : { + "first" : { + "href" : "http://sae-java.alix-jdlm.fr/api/v1/difficultes?page=0&size=2" + }, + "self" : { + "href" : "http://sae-java.alix-jdlm.fr/api/v1/difficultes?page=0&size=2" + }, + "next" : { + "href" : "http://sae-java.alix-jdlm.fr/api/v1/difficultes?page=1&size=2" + }, + "last" : { + "href" : "http://sae-java.alix-jdlm.fr/api/v1/difficultes?page=1&size=2" + } + }, + "page" : { + "size" : 2, + "totalElements" : 3, + "totalPages" : 2, + "number" : 0 + }, + "_embedded" : [ { + "id" : 1, + "libelle" : "Facile" + }, { + "id" : 2, + "libelle" : "Intermédiaire" + } ] +} +*/ +