Back

Appwrite not getting imported in Js

  • 0
  • Web
Aarush Acharya
21 Jan, 2024, 12:32

Hey this is my html file

TypeScript
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Button Example</title>
    <script type="module">
        console.log("appwrite.js loaded");
        import { Client, Account } from "appwrite";
    </script>
</head>
<body>
    <h1>Button Example</h1>
    <button id="myButton">Click me!</button>
</body>
</html>

Here is my py file I am using fast api

TypeScript
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates

app = FastAPI()

app.mount("/static", StaticFiles(directory="static"), name="static")


templates = Jinja2Templates(directory="")


@app.get("/", response_class=HTMLResponse)
async def read_item(request: Request):
    return templates.TemplateResponse("index.html", {"request": request})```


I am stuck with this error 

127.0.0.1/:1 Uncaught TypeError: Failed to resolve module specifier "appwrite". Relative references must start with either "/", "./", or "../".

Please do help
TL;DR
Issue: The appwrite module is not being imported in the JavaScript file. Solution: In the HTML file, make sure to specify the correct path for the appwrite module import. It should start with either "/", "./", or "../" to indicate a relative reference. Example: ```js <script type="module"> console.log("appwrite.js loaded"); import { Client, Account } from "./path/to/appwrite"; </script> ``` Additional notes: The user also mentioned using FastAPI and needing authentication with appwrite, but it's unclear how that is related to the import issue.
Philipp
21 Jan, 2024, 12:35

what does fastapi have to do with appwrite?

Aarush Acharya
21 Jan, 2024, 12:37

I was building my website using fast api, rendering html template and now I need auth in it so using appwrite for it

Aarush Acharya
21 Jan, 2024, 12:42

Please do help me figure this out

Aarush Acharya
21 Jan, 2024, 12:46

@Philipp am I doing something wrong?

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