0👍
So what happened was two things:
- I didn’t return the ref inside an object in the composable. I did return
recipe
instead of return{recipe}
import $ from "jquery";
import { ref } from "vue";
const getPost = (id) => {
const recipe = ref(null);
$.get(`https://www.themealdb.com/api/json/v1/1/lookup.php?i=${id}`,
function (data) {
const [meals] = data.meals;
recipe.value = meals;
}
);
return { recipe };
};
export default getPost;
- Instead of onMount, I did a
console.log
with a watcher:
watch(recipe, ()=>{
console.log(recipe.value);
})
Source:stackexchange.com