I do a request (fetch) in JSON file and y want to save a response's part in variable to export it in a VUE.js component. But the value don't change.
let Name ="0";
fetch("./src/assets/dataUser.json")
.then(response => response.json())
.then(response => {Name = response["prenom"]; console.log(Name)});
export default{
data () {
return {
firstname: Name
}
}
}
The log return the name but the value stay at "0". This is scop probleme but i don't know how to solved that.