1
I need to pass a variable inside an item array, a parameter that only accepts string, but when I pass a variable the API does not accept, it says that the parameter is incorrect.
Better explaining:
var userstocreate = [
{
username: 'aqui a variavel',
password: 'senha',
firstname: 'nome',
lastname: 'sobrenome',
email: 'email'
}
In the username where is 'here the variable' I have to pass between simple quotes.
Someone has a light to do it?
Got it, thanks for all your help.
var userstocreate = [
{
username: '' + usuario + '',
password: 'E@d123456',
firstname: '' + primeiro +'',
lastname: '' + lastname + '',
email: '' + email + ''
}
];
var primeiro = this.firstname.toString();
var usuario = this.username.toString();
var lastname = this.lastname.toString();
var email = this.email.toString();
The variable that Voce is trying to pass is already a string?
– raphael valerio
Yes var user = this.username; is a string, I have tried to convert I have already created a variable for example var name = "starname"; ai when I try to put in usernaem : name. does not work at all.
– Yuri Rodrigues
You’ve tried to get past her without any kind of conversation?
– raphael valerio
Already tried Raphael, this API is from MOODLE I need to make a student registration coming from the bank of the institution, it’s all ready, already listed the students, already has the service, that brings everything in json, ta all ready, just need to put the variable inside the array of users.
– Yuri Rodrigues
have done that. var user = "user agoravai" var userstocreate = [ , username: user, password: 'E@d 123456', firstname: 'testfirstname1', lastname: 'testlastname1', email: 'stage [email protected]' } ];
– Yuri Rodrigues
tries this concatenation, username: '"'+ username + '"',
– raphael valerio
@Yurirodrigues Poste as answer instead of editing the content of the question.
– Jéf Bueno