Back

¿Alguien me puede explicar como crear un login?

  • 0
  • Web
Gaby
11 Dec, 2023, 05:48

Estoy intentado crear un login siguiendo la documentación, usando un cdn pero me sale este error:

script.js:2 Uncaught SyntaxError: The requested module 'https://cdn.jsdelivr.net/npm/appwrite@13.0.1' does not provide an export named 'Account' (at script.js:2:19)

No se como vincular correctamente el appwrite con mis archivos de js para poder usarlos, ayuda por favor.

TL;DR
Person is asking for help on how to create a login using a CDN and Appwrite. They are receiving an error message about the requested module not providing an export named 'Account'. They need assistance in correctly linking Appwrite with their JavaScript files to be able to use them. Solution: The person needs to create a variable for the account (Account) and import the necessary modules correctly. They can try the following code: ```javascript import { Client, Account, ID } from 'https://cdn.jsdelivr.net/npm/appwrite@13.0.1'; export const client = new Client(); client .setEndpoint('https://
Drake
11 Dec, 2023, 06:00

English please?

Drake
11 Dec, 2023, 06:01

And what's your code?

Gaby
11 Dec, 2023, 19:15

This is my js:

import { Client, Account, ID } from 'https://cdn.jsdelivr.net/npm/appwrite@13.0.1';

export const client = new Client();

client .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint .setProject('ID') // Your project ID ;

// Función para registrar un nuevo usuario export function register() { const email = document.getElementById('registerEmail').value; const password = document.getElementById('registerPassword').value;

TypeScript
const promise = account.create(email, password, '');

promise.then(function (response) {
    console.log('Usuario registrado:', response);
    alert('Usuario registrado con éxito');
}, function (error) {
    console.error('Error al registrar usuario:', error);
    alert('Error al registrar usuario');
});
Gaby
11 Dec, 2023, 19:15

and it seems that this is wrong: import { Client, Account, ID } from 'https://cdn.jsdelivr.net/npm/appwrite@13.0.1';

D5
11 Dec, 2023, 21:10

Hola! parece ser que no has creado una variable para la cuenta (Account)

Hello! looks like that you have not created a variable for the account

D5
11 Dec, 2023, 21:11

Tienes que crear una variable así, para que la parte de la cuenta sea reconocida:

TypeScript
const account = new Account(client);

You need to create a veriable like this, to make the account part to be recognized:

Gaby
12 Dec, 2023, 20:46

ohh vale, muchisimas gracias, lo voy a probar

D5
12 Dec, 2023, 20:57

De nada! Dime si eso soluciona tu problema o no.

Your welcome! Tell me if that solves your issue or not.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more