I'm trying to send a nested object from my frontend to the backend.
My classes are:
interface ParamsUri {
iD: number,
from: string,
to: string,
nestedClass: string[]
}
interface Params {
iD: number,
from: string,
to: string,
nestedClass: NestedClass[]
}
class NestedClass{
name: string;
value: string;
}
My http.get command is:
this.http.Get<SomeClass[]>(`api/dashboardfilter`, this.GetParams(paramsUri))
While GetParms is:
private GetParams(params: Parmas): ParamsUri{
return {
id: 1,
from: "temp",
to: "temp",
nestedClass: params.nestedClass.map(x => stringify(x))
}
}
When console.log(this.GetParams(params).nestedClass, I see what I would expect, i.e., name=XXX&value=YY (one cell of the array). However, when I send the request and follow the query I see that '=' and '&' values were encoded by the get function those the query string is no longer readable to the backend (or at least this is my assumption of why I get null in for those values). I can also confirm that everything other then the nestedclass is received by the backend. I tried other methods to stringify my params (like simple mapping and join) but with no luck.
What am I missing? everywhere I look I find the same answer stringify your nested object, however, this seems to not work as the get function is encoding the stringify string.