Angular: Put logged in user id in the payloadAngular no provider for NameServiceAngular HTML binding@Directive v/s @Component in AngularAngular and Typescript: Can't find namesHow can I get new selection in “select” in Angular 2?Define global constants in Angular 2What is the equivalent of ngShow and ngHide in Angular 2+?Huge number of files generated for every Angular projectHow to Write test for login component for angular2 ( unit testing )Angular HTTP request
What does the "DS" in "DS-..." US visa application forms stand for?
How do carbureted and fuel injected engines compare in high altitude?
Why do 3D printers have only one limit switch?
Is there any evidence to support the claim that the United States was "suckered into WW1" by Zionists, made by Benjamin Freedman in his 1961 speech
What can cause an unfrozen indoor copper drain pipe to crack?
Can the president of the United States be guilty of insider trading?
Two (probably) equal real numbers which are not proved to be equal?
Can I bring back Planetary Romance as a genre?
Origins of the "array like" strings in BASIC
How long can fsck take on a 30 TB volume?
Are wands in any sort of book going to be too much like Harry Potter?
Best species to breed to intelligence
What is the Ancient One's mistake?
if i accidentally leaked my schools ip address and someone d doses my school am i at fault
How does weapons training transfer to empty hand?
Add Columns to .csv from Multiple Files
Has everyone forgotten about wildfire?
Do Monks gain the 9th level Unarmored Movement benefit when wearing armor or using a shield?
Passport stamps art, can it be done?
I might have messed up in the 'Future Work' section of my thesis
Narcissistic cube asks who are we?
What are these round pads on the bottom of a PCB?
Publishing an article in a journal without a related degree
What is the radius of the circle in this problem?
Angular: Put logged in user id in the payload
Angular no provider for NameServiceAngular HTML binding@Directive v/s @Component in AngularAngular and Typescript: Can't find namesHow can I get new selection in “select” in Angular 2?Define global constants in Angular 2What is the equivalent of ngShow and ngHide in Angular 2+?Huge number of files generated for every Angular projectHow to Write test for login component for angular2 ( unit testing )Angular HTTP request
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
how can I get the user id that logged in into the system and put the user id in the payload if the user wants to update their data base on their id without the user put their id manually?
MY LOGIN COMPONENT
export class LoginComponent
studentForm: FormGroup;
student: any;
constructor(
private fb: FormBuilder,
private crudService: CrudService,
private router: Router,
private toastr: ToastrService)
this.studentForm = this.fb.group(
id: ['', Validators.compose([Validators.required])],
password: ['', Validators.compose([Validators.required])]
);
saveStudentDetails(values)
const studentData = ;
studentData['id'] = values.id;
studentData['password'] = values.password;
this.crudService.loginstudent(studentData).subscribe(result =>
this.student = result;
this.toastr.success('You are logged in', 'Success !', positionClass: 'toast-bottom-right' );
console.log(this.crudService.loginstudent);
this.router.navigate(['/address']);
,
err =>
console.log('status code ->' + err.status);
this.toastr.error('Please try again', 'Error !', positionClass: 'toast-bottom-right' );
);
// MY EDIT COMPONENT
saveStudentDetails(values)
// const studentData = new FormData();
const studentData = ;
studentData['s_pNumber'] = values.s_pNumber;
studentData['s_address'] = values.s_address;
studentData['s_pCode'] = values.s_pCode;
studentData['s_city'] = values.s_city;
studentData['s_state'] = values.s_state;
studentData['s_country'] = values.s_country;
this.crudService.createAddress(studentData).subscribe(result =>
// this.student = result;
this.toastr.success('Your data has been inserted', 'Success !', positionClass: 'toast-bottom-right' );
// this.router.navigate(['/finance']);
,
err =>
console.log('status code ->' + err.status);
this.toastr.error('Please try again', 'Error !', positionClass: 'toast-bottom-right' );
);
// THIS IS MY SERVICE
createAddress(data)
const postHttpOptions =
headers: new HttpHeaders(
'Content-Type': 'application/json'
)
;
postHttpOptions['observe'] = 'response';
return this.http.put(this.url + '/address/$id', data);
I don't know if I'm doing the right thing, can anyone help me how to include the user id in the payload to be sent to backend? thank you
angular typescript angular7
add a comment |
how can I get the user id that logged in into the system and put the user id in the payload if the user wants to update their data base on their id without the user put their id manually?
MY LOGIN COMPONENT
export class LoginComponent
studentForm: FormGroup;
student: any;
constructor(
private fb: FormBuilder,
private crudService: CrudService,
private router: Router,
private toastr: ToastrService)
this.studentForm = this.fb.group(
id: ['', Validators.compose([Validators.required])],
password: ['', Validators.compose([Validators.required])]
);
saveStudentDetails(values)
const studentData = ;
studentData['id'] = values.id;
studentData['password'] = values.password;
this.crudService.loginstudent(studentData).subscribe(result =>
this.student = result;
this.toastr.success('You are logged in', 'Success !', positionClass: 'toast-bottom-right' );
console.log(this.crudService.loginstudent);
this.router.navigate(['/address']);
,
err =>
console.log('status code ->' + err.status);
this.toastr.error('Please try again', 'Error !', positionClass: 'toast-bottom-right' );
);
// MY EDIT COMPONENT
saveStudentDetails(values)
// const studentData = new FormData();
const studentData = ;
studentData['s_pNumber'] = values.s_pNumber;
studentData['s_address'] = values.s_address;
studentData['s_pCode'] = values.s_pCode;
studentData['s_city'] = values.s_city;
studentData['s_state'] = values.s_state;
studentData['s_country'] = values.s_country;
this.crudService.createAddress(studentData).subscribe(result =>
// this.student = result;
this.toastr.success('Your data has been inserted', 'Success !', positionClass: 'toast-bottom-right' );
// this.router.navigate(['/finance']);
,
err =>
console.log('status code ->' + err.status);
this.toastr.error('Please try again', 'Error !', positionClass: 'toast-bottom-right' );
);
// THIS IS MY SERVICE
createAddress(data)
const postHttpOptions =
headers: new HttpHeaders(
'Content-Type': 'application/json'
)
;
postHttpOptions['observe'] = 'response';
return this.http.put(this.url + '/address/$id', data);
I don't know if I'm doing the right thing, can anyone help me how to include the user id in the payload to be sent to backend? thank you
angular typescript angular7
add a comment |
how can I get the user id that logged in into the system and put the user id in the payload if the user wants to update their data base on their id without the user put their id manually?
MY LOGIN COMPONENT
export class LoginComponent
studentForm: FormGroup;
student: any;
constructor(
private fb: FormBuilder,
private crudService: CrudService,
private router: Router,
private toastr: ToastrService)
this.studentForm = this.fb.group(
id: ['', Validators.compose([Validators.required])],
password: ['', Validators.compose([Validators.required])]
);
saveStudentDetails(values)
const studentData = ;
studentData['id'] = values.id;
studentData['password'] = values.password;
this.crudService.loginstudent(studentData).subscribe(result =>
this.student = result;
this.toastr.success('You are logged in', 'Success !', positionClass: 'toast-bottom-right' );
console.log(this.crudService.loginstudent);
this.router.navigate(['/address']);
,
err =>
console.log('status code ->' + err.status);
this.toastr.error('Please try again', 'Error !', positionClass: 'toast-bottom-right' );
);
// MY EDIT COMPONENT
saveStudentDetails(values)
// const studentData = new FormData();
const studentData = ;
studentData['s_pNumber'] = values.s_pNumber;
studentData['s_address'] = values.s_address;
studentData['s_pCode'] = values.s_pCode;
studentData['s_city'] = values.s_city;
studentData['s_state'] = values.s_state;
studentData['s_country'] = values.s_country;
this.crudService.createAddress(studentData).subscribe(result =>
// this.student = result;
this.toastr.success('Your data has been inserted', 'Success !', positionClass: 'toast-bottom-right' );
// this.router.navigate(['/finance']);
,
err =>
console.log('status code ->' + err.status);
this.toastr.error('Please try again', 'Error !', positionClass: 'toast-bottom-right' );
);
// THIS IS MY SERVICE
createAddress(data)
const postHttpOptions =
headers: new HttpHeaders(
'Content-Type': 'application/json'
)
;
postHttpOptions['observe'] = 'response';
return this.http.put(this.url + '/address/$id', data);
I don't know if I'm doing the right thing, can anyone help me how to include the user id in the payload to be sent to backend? thank you
angular typescript angular7
how can I get the user id that logged in into the system and put the user id in the payload if the user wants to update their data base on their id without the user put their id manually?
MY LOGIN COMPONENT
export class LoginComponent
studentForm: FormGroup;
student: any;
constructor(
private fb: FormBuilder,
private crudService: CrudService,
private router: Router,
private toastr: ToastrService)
this.studentForm = this.fb.group(
id: ['', Validators.compose([Validators.required])],
password: ['', Validators.compose([Validators.required])]
);
saveStudentDetails(values)
const studentData = ;
studentData['id'] = values.id;
studentData['password'] = values.password;
this.crudService.loginstudent(studentData).subscribe(result =>
this.student = result;
this.toastr.success('You are logged in', 'Success !', positionClass: 'toast-bottom-right' );
console.log(this.crudService.loginstudent);
this.router.navigate(['/address']);
,
err =>
console.log('status code ->' + err.status);
this.toastr.error('Please try again', 'Error !', positionClass: 'toast-bottom-right' );
);
// MY EDIT COMPONENT
saveStudentDetails(values)
// const studentData = new FormData();
const studentData = ;
studentData['s_pNumber'] = values.s_pNumber;
studentData['s_address'] = values.s_address;
studentData['s_pCode'] = values.s_pCode;
studentData['s_city'] = values.s_city;
studentData['s_state'] = values.s_state;
studentData['s_country'] = values.s_country;
this.crudService.createAddress(studentData).subscribe(result =>
// this.student = result;
this.toastr.success('Your data has been inserted', 'Success !', positionClass: 'toast-bottom-right' );
// this.router.navigate(['/finance']);
,
err =>
console.log('status code ->' + err.status);
this.toastr.error('Please try again', 'Error !', positionClass: 'toast-bottom-right' );
);
// THIS IS MY SERVICE
createAddress(data)
const postHttpOptions =
headers: new HttpHeaders(
'Content-Type': 'application/json'
)
;
postHttpOptions['observe'] = 'response';
return this.http.put(this.url + '/address/$id', data);
I don't know if I'm doing the right thing, can anyone help me how to include the user id in the payload to be sent to backend? thank you
angular typescript angular7
angular typescript angular7
asked Mar 23 at 8:45
Hisyam SyazaniHisyam Syazani
319
319
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
// Change this
return this.http.put(this.url + '/address/$id', data);
//to this
return this.http.put(`$this.url/address/$id`, data);
//use the backtick
`
// not this
'
An image showing the backtick
my payload still did not have the user id imgur.com/U1nCkps . How can i put the user id in the payload?
– Hisyam Syazani
Mar 23 at 10:06
You are using the single quotes instead of backticks
– Sivuyile TG Magutywa
Mar 25 at 4:40
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%2f55312076%2fangular-put-logged-in-user-id-in-the-payload%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
// Change this
return this.http.put(this.url + '/address/$id', data);
//to this
return this.http.put(`$this.url/address/$id`, data);
//use the backtick
`
// not this
'
An image showing the backtick
my payload still did not have the user id imgur.com/U1nCkps . How can i put the user id in the payload?
– Hisyam Syazani
Mar 23 at 10:06
You are using the single quotes instead of backticks
– Sivuyile TG Magutywa
Mar 25 at 4:40
add a comment |
// Change this
return this.http.put(this.url + '/address/$id', data);
//to this
return this.http.put(`$this.url/address/$id`, data);
//use the backtick
`
// not this
'
An image showing the backtick
my payload still did not have the user id imgur.com/U1nCkps . How can i put the user id in the payload?
– Hisyam Syazani
Mar 23 at 10:06
You are using the single quotes instead of backticks
– Sivuyile TG Magutywa
Mar 25 at 4:40
add a comment |
// Change this
return this.http.put(this.url + '/address/$id', data);
//to this
return this.http.put(`$this.url/address/$id`, data);
//use the backtick
`
// not this
'
An image showing the backtick
// Change this
return this.http.put(this.url + '/address/$id', data);
//to this
return this.http.put(`$this.url/address/$id`, data);
//use the backtick
`
// not this
'
An image showing the backtick
// Change this
return this.http.put(this.url + '/address/$id', data);
//to this
return this.http.put(`$this.url/address/$id`, data);
//use the backtick
`
// not this
'
// Change this
return this.http.put(this.url + '/address/$id', data);
//to this
return this.http.put(`$this.url/address/$id`, data);
//use the backtick
`
// not this
'
edited Mar 25 at 4:48
answered Mar 23 at 9:03
Sivuyile TG MagutywaSivuyile TG Magutywa
4325
4325
my payload still did not have the user id imgur.com/U1nCkps . How can i put the user id in the payload?
– Hisyam Syazani
Mar 23 at 10:06
You are using the single quotes instead of backticks
– Sivuyile TG Magutywa
Mar 25 at 4:40
add a comment |
my payload still did not have the user id imgur.com/U1nCkps . How can i put the user id in the payload?
– Hisyam Syazani
Mar 23 at 10:06
You are using the single quotes instead of backticks
– Sivuyile TG Magutywa
Mar 25 at 4:40
my payload still did not have the user id imgur.com/U1nCkps . How can i put the user id in the payload?
– Hisyam Syazani
Mar 23 at 10:06
my payload still did not have the user id imgur.com/U1nCkps . How can i put the user id in the payload?
– Hisyam Syazani
Mar 23 at 10:06
You are using the single quotes instead of backticks
– Sivuyile TG Magutywa
Mar 25 at 4:40
You are using the single quotes instead of backticks
– Sivuyile TG Magutywa
Mar 25 at 4:40
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%2f55312076%2fangular-put-logged-in-user-id-in-the-payload%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