You can use other libraries when you're writing Vucript.
Let's use HTTP requiest library axios with Vucript.
Let's see the example which is using yesno API which returns YES or NO randomly.
import { 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 };
},
});