fix paths
This commit is contained in:
+5
-5
@@ -55,8 +55,8 @@ const getHeaders = (auth?: boolean): Headers => {
|
|||||||
|
|
||||||
const fillUrlParams = (apiPath: APIPath, params: API["urlParams"] = {}): string => {
|
const fillUrlParams = (apiPath: APIPath, params: API["urlParams"] = {}): string => {
|
||||||
const path = apiPath
|
const path = apiPath
|
||||||
.split("/")
|
.split("/") // ["", jobads", ":id"]
|
||||||
.filter(Boolean)
|
.filter(Boolean) // [jobads", ":id"]
|
||||||
.map((urlComponent) => {
|
.map((urlComponent) => {
|
||||||
// fill in each placeholder component like ':id' with value from params
|
// fill in each placeholder component like ':id' with value from params
|
||||||
if (urlComponent.startsWith(":")) {
|
if (urlComponent.startsWith(":")) {
|
||||||
@@ -66,9 +66,9 @@ const fillUrlParams = (apiPath: APIPath, params: API["urlParams"] = {}): string
|
|||||||
}
|
}
|
||||||
return urlComponent;
|
return urlComponent;
|
||||||
})
|
})
|
||||||
.join("/");
|
.join("/"); // "jobads/:id"
|
||||||
// code above strips leading '/' from path
|
// code above strips leading and trailing '/' from path
|
||||||
return `/${path}`;
|
return `/${path}/`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const callBackendAPI = async <RequestType, ResponseType>(
|
const callBackendAPI = async <RequestType, ResponseType>(
|
||||||
|
|||||||
Reference in New Issue
Block a user