#Keeps saying cannot read properties of undefined

1 messages · Page 1 of 1 (latest)

proud anchor
#

Please help im confused on what i have to do

queen thunder
proud anchor
#

for the first error: databases.listDocuments(collectionId, [
Query.equal('title', 'Avatar'), // Use Query.equal() for equal conditions
Query.select([
'Author',
'Title',
'Date_Time', // Change to camelCase or any valid variable name
'Email',
'Content',
'KeyPoints'
])
], {
limit: 10,
offset: 0,
orderField: 'createdAt', // Specify the field to be used for sorting
orderType: 'desc' // Specify the sorting order, 'desc' for descending, 'asc' for ascending
}).then(response => {
if (response.documents) {
response.documents.forEach(document => {
const author = document.Author;
const title = document.Title;
const dateTime = document['Date_Time']; // Use square brackets to access properties with hyphens
const email = document.Email;
const content = document.Content;
const keyPoints = document.KeyPoints;

        console.log(author, title, dateTime, email, content, keyPoints);
    });
} else {
    console.log('No documents found');
}

});

#

2nd error: account.create(ID.unique(), ''', '', '')
.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});

queen thunder
queen thunder
proud anchor
#

Im sry i need to leave... i'll come back in abit

proud anchor
queen thunder
queen thunder
proud anchor
proud anchor
#

console.log('JavaScript file is loaded.');

var alerted = localStorage.getItem('alerted') || '';
if (alerted != 'yes') {
alert("This website is under development if there are any issues please email me at [email protected]");
localStorage.setItem('alerted','yes');
console.log("It worked")
}
else {
console.log("Already alerted");
}

const { Client, Databases, Query } = Appwrite;

const client = new Client()
.setEndpoint('https://cloud.appwrite.io/v1')
.setProject('');

const account = new Account(client);

// Register the user using the account.create function
account.create(ID.unique(), '', ', '')
.then(function (response) {
    console.log(response);
}, function (error) {
    console.log(error);
});

const databases = new Databases();

const collectionId = '';
databases.listDocuments(collectionId, [
Query.equal('title', 'Avatar'), // Use Query.equal() for equal conditions
Query.select([
'Author',
'Title',
'Date_Time',
'Email',
'Content',
'KeyPoints'
])
], {
limit: 10,
offset: 0,
orderField: 'createdAt',
orderType: 'desc'
}).then(response => {
if (response.documents) {
response.documents.forEach(document => {
const author = document.Author;
const title = document.Title;
const dateTime = document['Date_Time']; // Use square brackets to access properties with hyphens
const email = document.Email;
const content = document.Content;
const keyPoints = document.KeyPoints;

        console.log(author, title, dateTime, email, content, keyPoints);
    });
} else {
    console.log('No documents found');
}

});

#

thats all the code for that javascript file

queen thunder
proud anchor
#

yep

queen thunder
proud anchor
queen thunder
proud anchor
#

The properties?? I deleted them on purpoes when i sent them..

queen thunder
#

const account = new Account(client);

Where's that Account defined?

#

because it's not here:

const { Client, Databases, Query } = Appwrite;
proud anchor
#

oops... i must have copied the wrong part of that... i edited to client.account.create

#

is that not a function?

queen thunder
proud anchor
#

Well.. you learn something new everyday.. Thanks for informing me!