add a slash before the path and a questionmark before the querystring
This commit is contained in:
parent
cfa5e5be73
commit
8709fb2f0b
|
@ -17,9 +17,9 @@
|
|||
|
||||
$: urlDisplay =
|
||||
schema.urlDisplay &&
|
||||
`${datasource.config.url}${query.fields.path ?? ""}${
|
||||
query.fields.queryString ?? ""
|
||||
}`
|
||||
`${datasource.config.url}${
|
||||
query.fields.path ? "/" + query.fields.path : ""
|
||||
}${query.fields.queryString ? "?" + query.fields.queryString : ""}`
|
||||
|
||||
function updateQuery({ detail }) {
|
||||
query.fields[schema.type] = detail.value
|
||||
|
|
|
@ -152,13 +152,17 @@ module RestModule {
|
|||
}
|
||||
}
|
||||
|
||||
getUrl(path: string, queryString: string): string {
|
||||
return `${this.config.url}/${path}?${queryString}`
|
||||
}
|
||||
|
||||
async create({ path = "", queryString = "", headers = {}, json = {} }) {
|
||||
this.headers = {
|
||||
...this.config.defaultHeaders,
|
||||
...headers,
|
||||
}
|
||||
|
||||
const response = await fetch(this.config.url + path + queryString, {
|
||||
const response = await fetch(this.getUrl(path, queryString), {
|
||||
method: "POST",
|
||||
headers: this.headers,
|
||||
body: JSON.stringify(json),
|
||||
|
@ -173,7 +177,7 @@ module RestModule {
|
|||
...headers,
|
||||
}
|
||||
|
||||
const response = await fetch(this.config.url + path + queryString, {
|
||||
const response = await fetch(this.getUrl(path, queryString), {
|
||||
headers: this.headers,
|
||||
})
|
||||
|
||||
|
@ -186,7 +190,7 @@ module RestModule {
|
|||
...headers,
|
||||
}
|
||||
|
||||
const response = await fetch(this.config.url + path + queryString, {
|
||||
const response = await fetch(this.getUrl(path, queryString), {
|
||||
method: "POST",
|
||||
headers: this.headers,
|
||||
body: JSON.stringify(json),
|
||||
|
@ -201,7 +205,7 @@ module RestModule {
|
|||
...headers,
|
||||
}
|
||||
|
||||
const response = await fetch(this.config.url + path + queryString, {
|
||||
const response = await fetch(this.getUrl(path, queryString), {
|
||||
method: "PATCH",
|
||||
headers: this.headers,
|
||||
body: JSON.stringify(json),
|
||||
|
@ -216,7 +220,7 @@ module RestModule {
|
|||
...headers,
|
||||
}
|
||||
|
||||
const response = await fetch(this.config.url + path + queryString, {
|
||||
const response = await fetch(this.getUrl(path, queryString), {
|
||||
method: "DELETE",
|
||||
headers: this.headers,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue