jsonvue.jscoldfusionformatfw1

Display JSON array in Vuejs


I'm getting this data from the Coldfusion Framework/1 API in JSON format:

{
  "COLUMNS": [
    "PRODUCT_ID",
    "PRODUCT_NAME",
    "PRODUCT_STATUS",
    "DT_CREATED"
  ],
  "DATA": [
    [
      102,
      "Window",
      "In Production",
      "November, 02 2018 10:33:13"
    ],
    [
      105,
      "Window",
      "Delivered",
      "November, 11 2018 15:00:00"
    ],
    ETC...
  ]
}

In developer tools, using Vue tool, I got this:

I'm using axios

new Vue({
    el: '#windows-list-data',
    data() {
      return {
      windows: null,
      loading: true,
      errored: false
    }
 },
mounted() {
  axios
    .get('https://my-server.local/index.cfm?action=api.get')
    .then( response => {
      this.windows = response.data

     })
    .catch( error =>  {
      console.log(error) 
      this.errored = true
    })
    .finally( () => this.loading = false )
}

Can someone tell me how to render the data in Vuejs in a view? thanks


Solution

  • seems should change

    this.windows = response.data
    

    to

    let respDataStr = response.data
    let jsObject = JSON.parse(respDataStr)
    this.windows = jsObject