我正在尝试从Vue中启用了CORS的API渲染表,但是页面上没有任何内容。当我按下“创建表格”按钮时,也会在控制台中收到此错误,该按钮应该构成API数据表格
<progress-button fill-color="#6b02a8" type="button" @click="createTable()">Create table</progress-button>
<table class="table table-bordered table-striped" id="traceRouteTable">
<tbody class="table">
<tr>
<th>Endpoint</th>
<th>Trace data</th>
</tr>
<tr v-for="value in tableData" :key="value.tableData">
<td>{{ value.endpoint }}</td>
<td>{{ value.trace_data }}</td>
</tr>
</tbody>
</table>
我正在使用以下功能按下显示数据的按钮:
sendBackData: function () { // Receive traceroute data, followed by the 'Generate data' button
var jobId = document.getElementById("jobId").innerHTML;
var message = '{"jobId":"' + jobId + '"}'; // jobId must NOT be changed
this.post('https://le75bkfcmg.execute-api.eu-west-2.amazonaws.com/dev/check-trace', message,
function(response) {
document.getElementById('report').innerHTML = response;
});
},
createTable: function () {
var tableData = '';
$.each(this.response, function(key, value) {
tableData += '<tr>';
tableData += '<td>' + value.endopoint + '</td>';
tableData += '<td>' + value.trace_data + '</td>';
tableData += '<tr>';
});
$('#traceRouteTable').append(tableData);
}
我正在尝试从sendBackData传递“响应”到存储API数据的createData函数,非常感谢您的帮助。我在控制台中遇到的错误:
[Vue warn]: Error in v-on handler: "TypeError: Cannot use 'in' operator to search for 'length' in {"errorMessage":"2019-08-06T08:21:30.219Z dc173b24-4582-4b80-83c2-6df65d8b2d68 Task timed out after 3.00 seconds"}"
found in
---> <VueProgressButton>
<ProperForm> at src/components/ProperForm.vue
<App> at src/App.vue
<Root>
TypeError: Cannot use 'in' operator to search for 'length' in {"errorMessage":"2019-08-06T08:21:30.219Z dc173b24-4582-4b80-83c2-6df65d8b2d68 Task timed out after 3.00 seconds"}
at isArrayLike (jquery.js?1157:502)
at Function.each (jquery.js?1157:364)
at VueComponent.createTable (ProperForm.vue?3dd5:93)
at click (eval at ./node_modules/cache-loader/dist/cjs.js?