我有点亮的 html 元素
我将使用 get 请求设置它们的内部 html
如何设置它们?
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>`;
}
}
// get 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;
}