Embarking on my journey with typescript and vuejs, I stumbled upon a perplexing error that has halted my progress for the past 48 hours. The error message reads as:
Type 'Users[]' is missing the following properties from type 'ArrayConstructor': isArray, prototype, from, of, [Symbol.species]
Here's a snippet from my GetAll.controller.ts
:
import { supabase } from "../server";
type Users = {
user_id: Number,
user_username: String,
user_email: String,
user_password: String,
user_token: String
}
export async function GetAll():Promise<Users[]> {
console.log('go');
try {
let { data, error } = await supabase
.from('users')
.select('*')
if (error) throw error
if (data) {
return data
} else {
throw data
}
} catch (err) { throw(err); }
}
Now, taking a look at my App.vue
:
<script lang="ts">
import {GetAll} from './API/GetAll.controller';
export default {
name: 'app',
data(){
return {
users: Array
}
},
async mounted() {
this.users = await GetAll()
}
}
</script>
The error seems to be lurking beneath the surface right after this.users
inside the mounted()
method.