ajouter params thematique et difficulte dans getpage

front
Gwenael PLANCHON 1 year ago
parent 0b801da9b5
commit d82ac8a6f8

@ -17,12 +17,18 @@ export class Scientifiques extends PagedDataObject{
constructor(parsedJSON){ constructor(parsedJSON){
super(parsedJSON, Scientifique) super(parsedJSON, Scientifique)
} }
static async getPage(pageNb, size=0){ static async getPage(pageNb, size=0, thematiqueId=-1, difficulteId=-1){
let sizeParam="" let params=""
if(size>=0){ if(size>0){
sizeParam=`&size=${size}` params+=`&size=${size}`
} }
const response = await fetch(`${REST_API}/scientifiques?page=${pageNb}${sizeParam}`) if(thematiqueId>-1){
params+=`&thematiqueId=${thematiqueId}`
}
if(difficulteId>-1){
params+=`&difficulteId=${difficulteId}`
}
const response = await fetch(`${REST_API}/scientifiques?page=${pageNb}${params}`)
return new this(await response.json()) return new this(await response.json())
} }
} }

Loading…
Cancel
Save