fix: 🐛 fixed bug that would cause driver view to contact vehicle endpoint and renamed driver type in vehicle view to be used properly

This commit is contained in:
2025-01-08 22:43:24 +01:00
parent d585c90a4e
commit 279bf5944e
2 changed files with 16 additions and 11 deletions

View File

@ -21,7 +21,7 @@ export default defineComponent({
headers.set('Content-Type', 'application/json')
headers.set('Accept', 'application/json')
const request: RequestInfo = new Request("/vehicle", {
const request: RequestInfo = new Request("http://localhost:5000/driver", {
method: "GET",
headers: headers
})
@ -38,7 +38,7 @@ export default defineComponent({
driverList.value.push({ id: jsonBody[i]["id"], name: jsonBody[i]["name"] })
}
} else {
alert(response.text)
console.log(await response.text())
}
}
@ -49,9 +49,12 @@ export default defineComponent({
headers.set('Content-Type', 'application/json')
headers.set('Accept', 'application/json')
const request: RequestInfo = new Request("/vehicle", {
const requestBody = JSON.stringify({ name: driverName.value });
const request: RequestInfo = new Request("http://localhost:5000/driver", {
method: "POST",
headers: headers
headers: headers,
body: requestBody
})
var response = await fetch(request)
@ -60,7 +63,7 @@ export default defineComponent({
var jsonBody = await response.json()
driverList.value.push({ id: jsonBody["body"], name: driverName.value })
} else {
alert(response.text)
console.log(await response.text())
}
}
@ -96,7 +99,6 @@ export default defineComponent({
<tr v-for="driver in driverList">
<th>{{ driver.id }}</th>
<td>{{ driver.name }}</td>
<td><a class="btn btn-warning">Open Editor</a></td>
</tr>
</tbody>
</table>

View File

@ -19,7 +19,7 @@ export default defineComponent({
headers.set('Content-Type', 'application/json')
headers.set('Accept', 'application/json')
const request: RequestInfo = new Request("/vehicle", {
const request: RequestInfo = new Request("http://localhost:5000/vehicle", {
method:"GET",
headers:headers
})
@ -34,7 +34,7 @@ export default defineComponent({
vehicleList.value.push({id: jsonBody[i]["id"], name: jsonBody[i]["name"]})
}
} else {
alert(response.text)
console.log(await response.text())
}
}
@ -45,9 +45,12 @@ export default defineComponent({
headers.set('Content-Type', 'application/json')
headers.set('Accept', 'application/json')
const request: RequestInfo = new Request("/vehicle", {
const requestBody = JSON.stringify({ name: vehicleName.value });
const request: RequestInfo = new Request("http://localhost:5000/vehicle", {
method:"POST",
headers:headers
headers:headers,
body: requestBody
})
var response = await fetch(request)
@ -56,7 +59,7 @@ export default defineComponent({
var jsonBody = await response.json()
vehicleList.value.push({id: jsonBody["body"], name: vehicleName.value})
} else {
alert(response.text)
console.log(await response.text())
}
}