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 path = apiPath
|
||||
.split("/")
|
||||
.filter(Boolean)
|
||||
.split("/") // ["", jobads", ":id"]
|
||||
.filter(Boolean) // [jobads", ":id"]
|
||||
.map((urlComponent) => {
|
||||
// fill in each placeholder component like ':id' with value from params
|
||||
if (urlComponent.startsWith(":")) {
|
||||
@@ -66,9 +66,9 @@ const fillUrlParams = (apiPath: APIPath, params: API["urlParams"] = {}): string
|
||||
}
|
||||
return urlComponent;
|
||||
})
|
||||
.join("/");
|
||||
// code above strips leading '/' from path
|
||||
return `/${path}`;
|
||||
.join("/"); // "jobads/:id"
|
||||
// code above strips leading and trailing '/' from path
|
||||
return `/${path}/`;
|
||||
};
|
||||
|
||||
const callBackendAPI = async <RequestType, ResponseType>(
|
||||
|
||||
Reference in New Issue
Block a user