Exploring VueJs for the first time and looking to split a string by comma (,) retrieved from an API into separate variables. The data is coming from a JSON server.
"featured-property": [
{
"id": "1",
"name": "Property 1",
"address": "Address Property 1",
"geo": "0.5307596, 101.4461512"
},
{
"id": "2",
"name": "Property 2",
"address": "Address Property 2",
"geo": "0.5055971577036701, 101.452919"
}
The goal is to parse the "geo" values, store them in variables "lat" and "lng", and use them with vue2-google-maps. Axios is being used to fetch the API.
export default{
name: 'PropertyDetail',
data(){
return{
property: [],
}
},
methods: {
setProperty(data){
this.property = data
},
},
mounted() {
axios
.get("http://localhost:3000/featured-property")
.then((response) => this.setProperty(response.data))
.catch((error) => console.log(error))
}
}
Seeking guidance on how to achieve this task using VueJS. Any advice would be appreciated!