Note: Using Flask & Reactjs
I'm currently struggling with a bug where I'm posting a 3-d array from my frontend to my backend and I'm trying to retrieve it using request.form.get('array',type=list), but it ends up being recieved as a 1d array.
Frontend:
let data = new FormData();
this.array = [[[1,4],[2,4]],[[3,1],[2,4]],[[7,4],[1,1]]]
data.append("array", this.array);
return axios
.post(this.url+`/post_arr`, data, {
headers: {
"Content-Type": "multipart/form-data",
},
})
.then((res) => {console.log('hi')
})
}) }
backend:
@app.route('/post_arr',methods=['POST'])
def test():
print(request.form.get('array',type=list))
>['1','4','2','4','3','1','2','4','7','4','1','1']
Rather than retrieving the array as a 3-d array, it retrieves it as a flattened 1d array, which is not ideal. Is there a way to solve this?