-
Notifications
You must be signed in to change notification settings - Fork 300
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Describe the feature
I have a nested query like filter[color]=red&filter[size]=large&user[product][id]=385&sort=-createdAt&include=author,comments&active=true. I want to get the raw query to transform the query into object with qs lib or I would like to see this on the getQuery.
An example how I use qs lib:
const query = "?filter[color]=red&filter[size]=large&user[product][id]=385&sort=-createdAt&include=author,comments&active=true";
const queryObject = qs.parse(query, {
ignoreQueryPrefix: true,
decoder: (str: string, defaultDecoder: qs.defaultDecoder, charset: string, type: "key" | "value") => {
if (type === "value" && !!Number(str)) {
return Number(str);
}
if (type === "value" && str === "true") {
return true;
}
if (type === "value" && str === "false") {
return false;
}
if (type === "value" && str.includes(",")) {
return str.split(",").map((s: string) => s.trim());
}
return defaultDecoder(str);
}
});Edit: One way to get the raw query is: const rawQuery = getRequestURL(event).search;
If I had the getRawQuery it will be better...
Additional information
- Would you be willing to help implement this feature?
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request