Studio: more fixes

This commit is contained in:
Pieter Vander Vennet 2023-10-16 15:06:50 +02:00
parent 3ceebaba12
commit 80b7a038cf
7 changed files with 129 additions and 77 deletions

View file

@ -22,9 +22,7 @@ export default class StudioServer {
async fetchLayer(layerId: string): Promise<LayerConfigJson> {
try {
return await Utils.downloadJson(
this.url + "/layers/" + layerId + "/" + layerId + ".json"
)
return await Utils.downloadJson(this.layerUrl(layerId))
} catch (e) {
return undefined
}
@ -35,7 +33,7 @@ export default class StudioServer {
if (id === undefined || id === "") {
return
}
await fetch(`${this.url}/layers/${id}/${id}.json`, {
await fetch(this.layerUrl(id), {
method: "POST",
headers: {
"Content-Type": "application/json;charset=utf-8",
@ -43,4 +41,8 @@ export default class StudioServer {
body: JSON.stringify(config, null, " "),
})
}
public layerUrl(id: string) {
return `${this.url}/layers/${id}/${id}.json`
}
}