Using Ohter Libraries
$ npm install axiosimport { reactive } from "Vucript";
import axios from "axios";
let yesorno: reactive<string> = 'thinking';
const onMounted = async () => {
try {
const response = await axios.get("https://yesno.wtf/api");
yesorno = response.data["answer"];
} catch (error) {
console.error(error);
}
};import { defineComponent, ref, onMounted } from "vue";
import axios from "axios";
export default defineComponent({
setup() {
const yesorno = ref<string>("thinking");
onMounted(async () => {
try {
const response = await axios.get("https://yesno.wtf/api");
yesorno.value = response.data["answer"];
} catch (error) {
console.error(error);
}
});
return { yesorno };
},
});Last updated