Angular: data sending from form (with raw / json options)
from my Angular 6 form I should send some data with the same configuration which I have in Postman (I send a screenshot with the complete configuration: as you can see, I choosen the options but raw / Json).
I tried the following example but it doesn't work because I receive a "bad request 400" error message, can you please help me? Thank all!
This is my code which doesn't work:
public login() {
let userPassword = this.registrationForm.get('password').value;
let userLogin = this.registrationForm.get('email').value;
let userLangKey = 'en';
/*
const transferObject = {
password: userPassword,
login: userLogin,
langKey: userLangKey
}
JSON.stringify(transferObject);
*/
const req = this.http.post('http://localhost:8080/api/register/', {
password: userPassword,
login: userLogin,
langkey: userLangKey
})
.subscribe(
res => {
console.log(res);
},
err => {
console.log("Error occured");
}
);
}
I also tried to edit my code in this way but I receive the same error:
(...)
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
};
const req = this.http.post('http://localhost:8080/api/register/', {
password: userPassword,
login: userLogin,
langkey: userLangKey
}, httpOptions)
.subscribe(
res => {
console.log(res);
},
err => {
console.log("Error occured");
}
(...)
angular
add a comment |
from my Angular 6 form I should send some data with the same configuration which I have in Postman (I send a screenshot with the complete configuration: as you can see, I choosen the options but raw / Json).
I tried the following example but it doesn't work because I receive a "bad request 400" error message, can you please help me? Thank all!
This is my code which doesn't work:
public login() {
let userPassword = this.registrationForm.get('password').value;
let userLogin = this.registrationForm.get('email').value;
let userLangKey = 'en';
/*
const transferObject = {
password: userPassword,
login: userLogin,
langKey: userLangKey
}
JSON.stringify(transferObject);
*/
const req = this.http.post('http://localhost:8080/api/register/', {
password: userPassword,
login: userLogin,
langkey: userLangKey
})
.subscribe(
res => {
console.log(res);
},
err => {
console.log("Error occured");
}
);
}
I also tried to edit my code in this way but I receive the same error:
(...)
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
};
const req = this.http.post('http://localhost:8080/api/register/', {
password: userPassword,
login: userLogin,
langkey: userLangKey
}, httpOptions)
.subscribe(
res => {
console.log(res);
},
err => {
console.log("Error occured");
}
(...)
angular
1
You could read the form values and create an object yourself, then just callJSON.stringify
on that object and send it as you send any other data.
– Teun van der Wijst
Nov 20 '18 at 9:19
Thank you very much for the absolutely quick response! Can you sent a little example, only i.e. whit one single data as an username? PS Make response as main question response and not here, so I can flag you as definitive solution!
– Archimede
Nov 20 '18 at 9:21
add a comment |
from my Angular 6 form I should send some data with the same configuration which I have in Postman (I send a screenshot with the complete configuration: as you can see, I choosen the options but raw / Json).
I tried the following example but it doesn't work because I receive a "bad request 400" error message, can you please help me? Thank all!
This is my code which doesn't work:
public login() {
let userPassword = this.registrationForm.get('password').value;
let userLogin = this.registrationForm.get('email').value;
let userLangKey = 'en';
/*
const transferObject = {
password: userPassword,
login: userLogin,
langKey: userLangKey
}
JSON.stringify(transferObject);
*/
const req = this.http.post('http://localhost:8080/api/register/', {
password: userPassword,
login: userLogin,
langkey: userLangKey
})
.subscribe(
res => {
console.log(res);
},
err => {
console.log("Error occured");
}
);
}
I also tried to edit my code in this way but I receive the same error:
(...)
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
};
const req = this.http.post('http://localhost:8080/api/register/', {
password: userPassword,
login: userLogin,
langkey: userLangKey
}, httpOptions)
.subscribe(
res => {
console.log(res);
},
err => {
console.log("Error occured");
}
(...)
angular
from my Angular 6 form I should send some data with the same configuration which I have in Postman (I send a screenshot with the complete configuration: as you can see, I choosen the options but raw / Json).
I tried the following example but it doesn't work because I receive a "bad request 400" error message, can you please help me? Thank all!
This is my code which doesn't work:
public login() {
let userPassword = this.registrationForm.get('password').value;
let userLogin = this.registrationForm.get('email').value;
let userLangKey = 'en';
/*
const transferObject = {
password: userPassword,
login: userLogin,
langKey: userLangKey
}
JSON.stringify(transferObject);
*/
const req = this.http.post('http://localhost:8080/api/register/', {
password: userPassword,
login: userLogin,
langkey: userLangKey
})
.subscribe(
res => {
console.log(res);
},
err => {
console.log("Error occured");
}
);
}
I also tried to edit my code in this way but I receive the same error:
(...)
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
};
const req = this.http.post('http://localhost:8080/api/register/', {
password: userPassword,
login: userLogin,
langkey: userLangKey
}, httpOptions)
.subscribe(
res => {
console.log(res);
},
err => {
console.log("Error occured");
}
(...)
angular
angular
edited Nov 20 '18 at 11:15
Archimede
asked Nov 20 '18 at 9:15
ArchimedeArchimede
101113
101113
1
You could read the form values and create an object yourself, then just callJSON.stringify
on that object and send it as you send any other data.
– Teun van der Wijst
Nov 20 '18 at 9:19
Thank you very much for the absolutely quick response! Can you sent a little example, only i.e. whit one single data as an username? PS Make response as main question response and not here, so I can flag you as definitive solution!
– Archimede
Nov 20 '18 at 9:21
add a comment |
1
You could read the form values and create an object yourself, then just callJSON.stringify
on that object and send it as you send any other data.
– Teun van der Wijst
Nov 20 '18 at 9:19
Thank you very much for the absolutely quick response! Can you sent a little example, only i.e. whit one single data as an username? PS Make response as main question response and not here, so I can flag you as definitive solution!
– Archimede
Nov 20 '18 at 9:21
1
1
You could read the form values and create an object yourself, then just call
JSON.stringify
on that object and send it as you send any other data.– Teun van der Wijst
Nov 20 '18 at 9:19
You could read the form values and create an object yourself, then just call
JSON.stringify
on that object and send it as you send any other data.– Teun van der Wijst
Nov 20 '18 at 9:19
Thank you very much for the absolutely quick response! Can you sent a little example, only i.e. whit one single data as an username? PS Make response as main question response and not here, so I can flag you as definitive solution!
– Archimede
Nov 20 '18 at 9:21
Thank you very much for the absolutely quick response! Can you sent a little example, only i.e. whit one single data as an username? PS Make response as main question response and not here, so I can flag you as definitive solution!
– Archimede
Nov 20 '18 at 9:21
add a comment |
3 Answers
3
active
oldest
votes
I'm not really sure how your form is built up so for this example I'm assuming you're using ngModel or you have already extracted the needed values from your form.
let l = 'test';
let p = 'pass';
let lk = 'en'
const transferObject = {
login: l,
password: p,
langKey: lk
}
const object JSON.stringify(transferObject);
// requires injecting HttpClient in constructor
this.http.post<object>('http://myurl.com', string);
Then on the receiving end you can reverse this action to get your object back like so:
let string = // receive your string
const receivedObject = JSON.parse(string)
You can read more about the Javascript/Typescript JSON functions here: https://www.w3schools.com/js/js_json_stringify.asp
Thank you! I have already retrieve my form data and convert with JSON.stringify; the problem is also not what happens after this operation because I should sent to a backend already developed and efficient. My only question is: how can I send this info to this backend? As you can see in attach "postman" configuration screenshot, all works correctly if in my "post" method to the link "localhost:8080/something..." I choose not "form" mode but "raw". Could you please sent me a row of example valid to send this info by post to this link but with "raw" option?
– Archimede
Nov 20 '18 at 10:15
1
angular.io/guide/http#making-a-post-request take a look here
– Teun van der Wijst
Nov 20 '18 at 10:19
Thanks but it is referred to a database maybe, I don't see the way to insert my link and the JSON.stringify which you indicated me before... This is the only piece which is not yet present in my "mosaic"! Thank you very much.
– Archimede
Nov 20 '18 at 10:33
Already re-edit my post with an example! Thank
– Archimede
Nov 20 '18 at 10:45
add a comment |
Please use third parameter to set headers for this post request.
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
};
this.http.post<Hero>(this.heroesUrl, hero, httpOptions)
I edited my main question with the application of your solution to my problem but I receive the same error; have I written something wrong? Thank you very much!
– Archimede
Nov 20 '18 at 11:14
add a comment |
I tried myself and solved the problem; considering my last code version I posted here, all was correct and the once problem was simply activate. In the previous http row, I only define this.(blablabla); it was enough at the end of this row ".subscribe(blablabla)" to activate the function. Only this command; nothing else. Thank; I copy below my correct code. I hope, it can be useful for someone else.
public login() {
let userPassword = this.registrationForm.get('password').value;
let userLogin = this.registrationForm.get('email').value;
let userLangKey = 'en';
const transferObject = {
password: userPassword,
login: userLogin,
langKey: userLangKey
}
let header:HttpHeaders = new HttpHeaders().set('Content-Type', 'application/json');
const object = JSON.stringify(transferObject);
const self = this;
//Here is the point!
return self.httpClient.post(PathService.authPath()+'register', object, {headers: header}).subscribe((response: Response) => {
this.helperService.snackBarWarning('all works correctly');
});
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389689%2fangular-data-sending-from-form-with-raw-json-options%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I'm not really sure how your form is built up so for this example I'm assuming you're using ngModel or you have already extracted the needed values from your form.
let l = 'test';
let p = 'pass';
let lk = 'en'
const transferObject = {
login: l,
password: p,
langKey: lk
}
const object JSON.stringify(transferObject);
// requires injecting HttpClient in constructor
this.http.post<object>('http://myurl.com', string);
Then on the receiving end you can reverse this action to get your object back like so:
let string = // receive your string
const receivedObject = JSON.parse(string)
You can read more about the Javascript/Typescript JSON functions here: https://www.w3schools.com/js/js_json_stringify.asp
Thank you! I have already retrieve my form data and convert with JSON.stringify; the problem is also not what happens after this operation because I should sent to a backend already developed and efficient. My only question is: how can I send this info to this backend? As you can see in attach "postman" configuration screenshot, all works correctly if in my "post" method to the link "localhost:8080/something..." I choose not "form" mode but "raw". Could you please sent me a row of example valid to send this info by post to this link but with "raw" option?
– Archimede
Nov 20 '18 at 10:15
1
angular.io/guide/http#making-a-post-request take a look here
– Teun van der Wijst
Nov 20 '18 at 10:19
Thanks but it is referred to a database maybe, I don't see the way to insert my link and the JSON.stringify which you indicated me before... This is the only piece which is not yet present in my "mosaic"! Thank you very much.
– Archimede
Nov 20 '18 at 10:33
Already re-edit my post with an example! Thank
– Archimede
Nov 20 '18 at 10:45
add a comment |
I'm not really sure how your form is built up so for this example I'm assuming you're using ngModel or you have already extracted the needed values from your form.
let l = 'test';
let p = 'pass';
let lk = 'en'
const transferObject = {
login: l,
password: p,
langKey: lk
}
const object JSON.stringify(transferObject);
// requires injecting HttpClient in constructor
this.http.post<object>('http://myurl.com', string);
Then on the receiving end you can reverse this action to get your object back like so:
let string = // receive your string
const receivedObject = JSON.parse(string)
You can read more about the Javascript/Typescript JSON functions here: https://www.w3schools.com/js/js_json_stringify.asp
Thank you! I have already retrieve my form data and convert with JSON.stringify; the problem is also not what happens after this operation because I should sent to a backend already developed and efficient. My only question is: how can I send this info to this backend? As you can see in attach "postman" configuration screenshot, all works correctly if in my "post" method to the link "localhost:8080/something..." I choose not "form" mode but "raw". Could you please sent me a row of example valid to send this info by post to this link but with "raw" option?
– Archimede
Nov 20 '18 at 10:15
1
angular.io/guide/http#making-a-post-request take a look here
– Teun van der Wijst
Nov 20 '18 at 10:19
Thanks but it is referred to a database maybe, I don't see the way to insert my link and the JSON.stringify which you indicated me before... This is the only piece which is not yet present in my "mosaic"! Thank you very much.
– Archimede
Nov 20 '18 at 10:33
Already re-edit my post with an example! Thank
– Archimede
Nov 20 '18 at 10:45
add a comment |
I'm not really sure how your form is built up so for this example I'm assuming you're using ngModel or you have already extracted the needed values from your form.
let l = 'test';
let p = 'pass';
let lk = 'en'
const transferObject = {
login: l,
password: p,
langKey: lk
}
const object JSON.stringify(transferObject);
// requires injecting HttpClient in constructor
this.http.post<object>('http://myurl.com', string);
Then on the receiving end you can reverse this action to get your object back like so:
let string = // receive your string
const receivedObject = JSON.parse(string)
You can read more about the Javascript/Typescript JSON functions here: https://www.w3schools.com/js/js_json_stringify.asp
I'm not really sure how your form is built up so for this example I'm assuming you're using ngModel or you have already extracted the needed values from your form.
let l = 'test';
let p = 'pass';
let lk = 'en'
const transferObject = {
login: l,
password: p,
langKey: lk
}
const object JSON.stringify(transferObject);
// requires injecting HttpClient in constructor
this.http.post<object>('http://myurl.com', string);
Then on the receiving end you can reverse this action to get your object back like so:
let string = // receive your string
const receivedObject = JSON.parse(string)
You can read more about the Javascript/Typescript JSON functions here: https://www.w3schools.com/js/js_json_stringify.asp
edited Nov 20 '18 at 10:36
answered Nov 20 '18 at 9:44
Teun van der WijstTeun van der Wijst
570215
570215
Thank you! I have already retrieve my form data and convert with JSON.stringify; the problem is also not what happens after this operation because I should sent to a backend already developed and efficient. My only question is: how can I send this info to this backend? As you can see in attach "postman" configuration screenshot, all works correctly if in my "post" method to the link "localhost:8080/something..." I choose not "form" mode but "raw". Could you please sent me a row of example valid to send this info by post to this link but with "raw" option?
– Archimede
Nov 20 '18 at 10:15
1
angular.io/guide/http#making-a-post-request take a look here
– Teun van der Wijst
Nov 20 '18 at 10:19
Thanks but it is referred to a database maybe, I don't see the way to insert my link and the JSON.stringify which you indicated me before... This is the only piece which is not yet present in my "mosaic"! Thank you very much.
– Archimede
Nov 20 '18 at 10:33
Already re-edit my post with an example! Thank
– Archimede
Nov 20 '18 at 10:45
add a comment |
Thank you! I have already retrieve my form data and convert with JSON.stringify; the problem is also not what happens after this operation because I should sent to a backend already developed and efficient. My only question is: how can I send this info to this backend? As you can see in attach "postman" configuration screenshot, all works correctly if in my "post" method to the link "localhost:8080/something..." I choose not "form" mode but "raw". Could you please sent me a row of example valid to send this info by post to this link but with "raw" option?
– Archimede
Nov 20 '18 at 10:15
1
angular.io/guide/http#making-a-post-request take a look here
– Teun van der Wijst
Nov 20 '18 at 10:19
Thanks but it is referred to a database maybe, I don't see the way to insert my link and the JSON.stringify which you indicated me before... This is the only piece which is not yet present in my "mosaic"! Thank you very much.
– Archimede
Nov 20 '18 at 10:33
Already re-edit my post with an example! Thank
– Archimede
Nov 20 '18 at 10:45
Thank you! I have already retrieve my form data and convert with JSON.stringify; the problem is also not what happens after this operation because I should sent to a backend already developed and efficient. My only question is: how can I send this info to this backend? As you can see in attach "postman" configuration screenshot, all works correctly if in my "post" method to the link "localhost:8080/something..." I choose not "form" mode but "raw". Could you please sent me a row of example valid to send this info by post to this link but with "raw" option?
– Archimede
Nov 20 '18 at 10:15
Thank you! I have already retrieve my form data and convert with JSON.stringify; the problem is also not what happens after this operation because I should sent to a backend already developed and efficient. My only question is: how can I send this info to this backend? As you can see in attach "postman" configuration screenshot, all works correctly if in my "post" method to the link "localhost:8080/something..." I choose not "form" mode but "raw". Could you please sent me a row of example valid to send this info by post to this link but with "raw" option?
– Archimede
Nov 20 '18 at 10:15
1
1
angular.io/guide/http#making-a-post-request take a look here
– Teun van der Wijst
Nov 20 '18 at 10:19
angular.io/guide/http#making-a-post-request take a look here
– Teun van der Wijst
Nov 20 '18 at 10:19
Thanks but it is referred to a database maybe, I don't see the way to insert my link and the JSON.stringify which you indicated me before... This is the only piece which is not yet present in my "mosaic"! Thank you very much.
– Archimede
Nov 20 '18 at 10:33
Thanks but it is referred to a database maybe, I don't see the way to insert my link and the JSON.stringify which you indicated me before... This is the only piece which is not yet present in my "mosaic"! Thank you very much.
– Archimede
Nov 20 '18 at 10:33
Already re-edit my post with an example! Thank
– Archimede
Nov 20 '18 at 10:45
Already re-edit my post with an example! Thank
– Archimede
Nov 20 '18 at 10:45
add a comment |
Please use third parameter to set headers for this post request.
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
};
this.http.post<Hero>(this.heroesUrl, hero, httpOptions)
I edited my main question with the application of your solution to my problem but I receive the same error; have I written something wrong? Thank you very much!
– Archimede
Nov 20 '18 at 11:14
add a comment |
Please use third parameter to set headers for this post request.
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
};
this.http.post<Hero>(this.heroesUrl, hero, httpOptions)
I edited my main question with the application of your solution to my problem but I receive the same error; have I written something wrong? Thank you very much!
– Archimede
Nov 20 '18 at 11:14
add a comment |
Please use third parameter to set headers for this post request.
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
};
this.http.post<Hero>(this.heroesUrl, hero, httpOptions)
Please use third parameter to set headers for this post request.
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
};
this.http.post<Hero>(this.heroesUrl, hero, httpOptions)
answered Nov 20 '18 at 11:08
shan22shan22
918
918
I edited my main question with the application of your solution to my problem but I receive the same error; have I written something wrong? Thank you very much!
– Archimede
Nov 20 '18 at 11:14
add a comment |
I edited my main question with the application of your solution to my problem but I receive the same error; have I written something wrong? Thank you very much!
– Archimede
Nov 20 '18 at 11:14
I edited my main question with the application of your solution to my problem but I receive the same error; have I written something wrong? Thank you very much!
– Archimede
Nov 20 '18 at 11:14
I edited my main question with the application of your solution to my problem but I receive the same error; have I written something wrong? Thank you very much!
– Archimede
Nov 20 '18 at 11:14
add a comment |
I tried myself and solved the problem; considering my last code version I posted here, all was correct and the once problem was simply activate. In the previous http row, I only define this.(blablabla); it was enough at the end of this row ".subscribe(blablabla)" to activate the function. Only this command; nothing else. Thank; I copy below my correct code. I hope, it can be useful for someone else.
public login() {
let userPassword = this.registrationForm.get('password').value;
let userLogin = this.registrationForm.get('email').value;
let userLangKey = 'en';
const transferObject = {
password: userPassword,
login: userLogin,
langKey: userLangKey
}
let header:HttpHeaders = new HttpHeaders().set('Content-Type', 'application/json');
const object = JSON.stringify(transferObject);
const self = this;
//Here is the point!
return self.httpClient.post(PathService.authPath()+'register', object, {headers: header}).subscribe((response: Response) => {
this.helperService.snackBarWarning('all works correctly');
});
}
add a comment |
I tried myself and solved the problem; considering my last code version I posted here, all was correct and the once problem was simply activate. In the previous http row, I only define this.(blablabla); it was enough at the end of this row ".subscribe(blablabla)" to activate the function. Only this command; nothing else. Thank; I copy below my correct code. I hope, it can be useful for someone else.
public login() {
let userPassword = this.registrationForm.get('password').value;
let userLogin = this.registrationForm.get('email').value;
let userLangKey = 'en';
const transferObject = {
password: userPassword,
login: userLogin,
langKey: userLangKey
}
let header:HttpHeaders = new HttpHeaders().set('Content-Type', 'application/json');
const object = JSON.stringify(transferObject);
const self = this;
//Here is the point!
return self.httpClient.post(PathService.authPath()+'register', object, {headers: header}).subscribe((response: Response) => {
this.helperService.snackBarWarning('all works correctly');
});
}
add a comment |
I tried myself and solved the problem; considering my last code version I posted here, all was correct and the once problem was simply activate. In the previous http row, I only define this.(blablabla); it was enough at the end of this row ".subscribe(blablabla)" to activate the function. Only this command; nothing else. Thank; I copy below my correct code. I hope, it can be useful for someone else.
public login() {
let userPassword = this.registrationForm.get('password').value;
let userLogin = this.registrationForm.get('email').value;
let userLangKey = 'en';
const transferObject = {
password: userPassword,
login: userLogin,
langKey: userLangKey
}
let header:HttpHeaders = new HttpHeaders().set('Content-Type', 'application/json');
const object = JSON.stringify(transferObject);
const self = this;
//Here is the point!
return self.httpClient.post(PathService.authPath()+'register', object, {headers: header}).subscribe((response: Response) => {
this.helperService.snackBarWarning('all works correctly');
});
}
I tried myself and solved the problem; considering my last code version I posted here, all was correct and the once problem was simply activate. In the previous http row, I only define this.(blablabla); it was enough at the end of this row ".subscribe(blablabla)" to activate the function. Only this command; nothing else. Thank; I copy below my correct code. I hope, it can be useful for someone else.
public login() {
let userPassword = this.registrationForm.get('password').value;
let userLogin = this.registrationForm.get('email').value;
let userLangKey = 'en';
const transferObject = {
password: userPassword,
login: userLogin,
langKey: userLangKey
}
let header:HttpHeaders = new HttpHeaders().set('Content-Type', 'application/json');
const object = JSON.stringify(transferObject);
const self = this;
//Here is the point!
return self.httpClient.post(PathService.authPath()+'register', object, {headers: header}).subscribe((response: Response) => {
this.helperService.snackBarWarning('all works correctly');
});
}
answered Nov 20 '18 at 15:28
ArchimedeArchimede
101113
101113
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389689%2fangular-data-sending-from-form-with-raw-json-options%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You could read the form values and create an object yourself, then just call
JSON.stringify
on that object and send it as you send any other data.– Teun van der Wijst
Nov 20 '18 at 9:19
Thank you very much for the absolutely quick response! Can you sent a little example, only i.e. whit one single data as an username? PS Make response as main question response and not here, so I can flag you as definitive solution!
– Archimede
Nov 20 '18 at 9:21