I need to send type related params in sparse fieldset way, please provide a way to construct below url.
const page = {
limit: 0,
offset:10,
type: {
name: 's',
age:'n'
}
}
i tried to convert above object with urlsearch params but still not getting like below url.
https://sample.run/api/product?limit=0&offset=10&type[name]=s&type[age]=n
2
Answers
You can use this code, the formatting is bit bad, but I hope your linter fixes it 🙂
Maybe this answer is more appropriate for you if you have multiple nested fields: Want to convert a nested object to query parameter for attaching to url