I’m struggling to get the device language to my backend when registering:
In my ClientSide ( Ionic ) , i’m getting the language with this way:
this.language = localStorage.getItem('language')
if (this.language === 'ar') {
this.language = 'Arabic'
} else {
this.language = 'English'
}
But couldn’t figure out how to get it when i’m registering my user, i want to store it in the database
here’s my ServerSide ( Meteor )
async function register(firstname, email, password, password2, next) {
if (!email) {
next(null, { error: 'NO_EMAIL', field: 'email' })
} else if (!password) {
next(null, { error: 'NO_PASSWORD', field: 'password' })
} else if (!firstname) {
next(null, { error: 'NO_FIRSTNAME', field: 'firstname' })
} else if (typeof (email) !== 'string' || email.length > 100) {
next(null, { error: 'BAD_EMAIL', field: 'email' })
} else if (typeof (password) !== 'string' || password.length > 100) {
next(null, { error: 'BAD_PASSWORD', field: 'password' })
} else if (typeof (firstname) !== 'string' || firstname.length > 100) {
next(null, { error: 'BAD_FIRSTNAME', field: 'firstname' })
} else if (password !== password2) {
next(null, { error: 'PASSWORDS_NOT_MATCHING', field: 'password' })
} else {
const credentials = {
profile: {
name: firstname
},
email,
password,
language
}
}
Is there a way to pass the language that i’m getting in my localstorage ( clientside ) to the register function ?