#Why am I getting empty data when doing JSON.stringify(model)
21 messages · Page 1 of 1 (latest)
// your code here
claimKey
:
"PCI0300147"
scode
:
"1505"
selcom
:
"test sid"
seven
:
"Test hk"
teamCode
:
"999"
ty
:
"BODY"
userName
:
"sprager"
data inside my model
Post the code you're using.
// your code here
createComments(model: CommentsDto | null | undefined): Observable<void> {
let url_ = this.baseUrl + "some data"; //ignore this
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(model);
let options_ : any = {
body: content_,
observe: "response",
responseType: "blob",
headers: new HttpHeaders({
"Content-Type": "application/json",
})
};
return this.http.request("post", url_, options_).pipe(_observableMergeMap((response_ : any) => {
return this.processCreateComments(response_);
})).pipe(_observableCatch((response_: any) => {
if (response_ instanceof HttpResponseBase) {
try {
return this.processCreateComments(response_ as any);
} catch (e) {
return _observableThrow(e) as any as Observable<void>;
}
} else
return _observableThrow(response_) as any as Observable<void>;
}));
}
Where are you logging content_?
How do you know that?
I just logged it on console.
.
And again: where do you put the log statement?
my friend. doing console.log(content_) is same as JSON.stringify(model)
Maybe is the same as console.log(JSON.stringify(model))
And for the third time: where are you inserting the log?
I am putting the content_ inside options and then hitting the api
I am talking in reference to the photo I have uploaded
Wouldyou please just tellme why am i not getting any value
Please, turn this part of your code
const content_ = JSON.stringify(model);
into this
const content_ = JSON.stringify(model);
console.log(content_)
And post what you get in console.
If it returns empty again, post how you generate the object you pass as model argument to your createComments function.
got it now. before I was adding all the values from the form to the model directly and then sending the model in api. Now, I passed the data parameters separately in api and it worked.