So I am calling the Parse.User.login() method. If the username/password combination are not correct, I get the corresponding error from parse. If if I am entering the correct ones, noting happens. Does anybody knows why?
This is my code
const ParsePlattform = require('parse/node')
export function initializeParseConnection() {
ParsePlattform.initialize(parseAppId, javaScriptKey)
ParsePlattform.serverURL = 'http://localhost:1337/parse'
return ParsePlattform
}
export function userLogin(username, password) {
return new Promise(function (resolve, reject) {
const parse = initializeParseConnection()
parse.User.logIn(username, password, {
success: (user) => {
// console.log will not even be triggered
console.log('triggered')
resolve(user)
},
error: (user, error) => {
// this gets triggered if I enter incorrect user/password combination
console.error('Error: ' + error.code + ' ' + error.message)
reject(error)
},
})
})
}
I call this function from a nuxt project/vue page
<template>
<main class="form-signin">
<form>
<div class="form-floating">
<input
type="text"
v-model="username"
/>
<label for="floatingInput">Benutzername</label>
</div>
<div class="form-floating">
<input
type="password"
class="form-control"
v-model="password"
/>
</div>
<button @click="login" class="w-100 btn btn-lg btn-primary">Login</button>
</form>
</main>
</template>
<script>
import { userLogin } from 'assets/js/parse'
export default {
name: 'Login',
layout: 'login',
data() {
return {
password: null,
username: null,
}
},
methods: {
async login() {
const user = await userLogin(this.username, this.password)
},
},
}
</script>
try with:
export async function userLogin(username, password) {
const parse = initializeParseConnection()
try {
const user = await parse.User.logIn(username, password)
console.log('triggered')
return user
} catch (error) {
console.error('Error: ' + error.code + ' ' + error.message)
throw error;
}
}