Need help setting inner html of html elements with a get request
Any suggestions on how to achieve this?
import { LitElement, html, css } from "lit";
import { customElement } from "lit/decorators.js";
import axios from "axios";
@customElement("s-profile")
export class Profile extends LitElement {
render() {
return html`<p>${getProfile()}</p>`;
}
}
// fetch data from api
async function getProfile(): Promise<string> {
const username = window.location.pathname.replace("/", "");
const result = await axios.get(
`http://localhost:8000/api/getProfile?username=${username}`
);
const data: string = (<any>result).data.result.username;
console.log(data);
return data;
}