0

How can I change EUR to USD to axios response with one button click

  data(){
      return {
        posts: ' ',
        errors: []
      }
  }
  mounted() {
    axios.get('http://data.fixer.io/api/latest?access_key=509c9d50c1e92a712be9c8f1f964cf67')
    .then(response => {
      // JSON responses are automatically parsed.
      this.posts = response.data.rates.EUR.toFixed(2)
    })
}
}
aravinvafshe
  • 277
  • 1
  • 5
  • 12
  • `response.data.rates.USD.toFixed(2)` Is that really what you're asking?? – Mark Jan 05 '20 at 17:36
  • @MarkMeyer Not really, I want it to be changed by clicking a button – aravinvafshe Jan 05 '20 at 17:40
  • 1
    Does this answer your question? [Dynamically access object property using variable](https://stackoverflow.com/questions/4244896/dynamically-access-object-property-using-variable) – yuriy636 Jan 05 '20 at 18:22
  • Once you get the response and assign it to your data variables, you're free to manipulate it however you want, so create a methods property and add methods to convert there. – Arc Jan 06 '20 at 02:19

0 Answers0