Closed tomaskallup closed 3 years ago
Could you try deactivated['from']
or deactivated.from
in the query string? Let me know if that works!
Neither of those works, still getting "deactivated.from" is not allowed
and "deactivated.['from']" is not allowed
.
You need to use parse_str
function from locutus
here. Or create you one with same behavoir.
example:
// const parse_str = require('locutus/php/strings/parse_str')
import parse_str from 'locutus/php/strings/parse_str'
const query_result = {}
const query_string = "?deactivated[from]=2019-05-23T08:18:45.283Z&deactivated[to]=2019-06-12T08:18:45.283Z".slice(1)
parse_str(query_string, query_result)
console.log(query_result);
// {
// deactivated: {
// from: '2019-05-23T08:18:45.283Z',
// to: '2019-06-12T08:18:45.283Z'
// }
// }
@aheckmann, please close this issue.
I wanted to validate a object in query string (
?deactivated[from]=2019-05-23T08:18:45.283Z&deactivated[to]=2019-06-12T08:18:45.283Z
) So I went ahead and tried:But the request just prints out (
"deactivated[from]" is not allowed
).I have discovered that
?deactivated={"from": "2019-01-01T08:18:45.283Z"}
works, but I would like the use the first approach, as that's how objects are converted to query string by default. Is there any way I can get this behaviour?From further testings, if I define the query like so:
It seems to work, but that's not a solution, the variable names are unusable.