This is my axios request
axios({
method: 'put',
url: url,
data: data
}).then(function (response) {
console.log(response.data)
})
.catch(function (error) {
console.log(error)
})
It's being made from a vue component to submit form data (a table component).
Then I've tried the following JSON objects for data
"building": {
"a": ['Level 1', 0.0, 0, '', '', true],
"b": ['Level 2', 3.8, 40, '', '', false],
"c": ['Level 3', 7.6, 50, '', '', false],
"d": ['Level 4', 11.4, 50, '', '', false]
} // keys not numeric
"building": {
"1": ['Level 1', 0.0, 0, '', '', true],
"2": ['Level 2', 3.8, 40, '', '', false],
"3": ['Level 3', 7.6, 50, '', '', false],
"4": ['Level 4', 11.4, 50, '', '', false]
} // keys don't start at 0
"building": {
"0": ['Level 1', 0.0, 0, '', '', true],
"2": ['Level 2', 3.8, 40, '', '', false],
"3": ['Level 3', 7.6, 50, '', '', false],
"4": ['Level 4', 11.4, 50, '', '', false]
} // keys not consecutive
"building": {
"0": ['Level 1', 0.0, 0, '', '', true],
"1": ['Level 2', 3.8, 40, '', '', false],
"2": ['Level 3', 7.6, 50, '', '', false],
"3": ['Level 4', 11.4, 50, '', '', false]
} // keys are numeric, consecutive, start at 0
The first 3 all remain as objects when I receive them but the 4th (numeric, consecutive, start at 0) gets converted to an array.
How do I stop this from happening?
Clarifications
- I want the data I receive to be an object
- PHP 8 is the backend receiving the put request and then sending the data straight back as the response
- I am doing
console.log(data)just before sending the axios request and that's an object for all 4. Then theconsole.log(response.data)is a object for the first 3 and an array for the last.