0

I am trying to send file with some other detail to flask from reactjs using FormData. I can get the file using request.files['file'] but while trying to run request.get_json flask returning CORS error to reactjs

ReactJS

const handletest=()=>{
const formdata=new FormData()
formdata.append("files",files)
formdata.append("name", "devi")
axios.post("http://localhost:5000/products",formdata)
.then((res)=>{
  console.log(res)
})
.catch((err)=>{
  console.log(err)
})}

FLask

@app.route('/products', methods=['POST'])
@cross_origin(supports_credentials=True)
def create_product():
    print("called")
    file=request.files['files']
    print(file)
    # print(jsonify(request))
    print(request.get_json())
    return "Success",201

I tried to get values using request.get_json but it is not working

davidism
  • 121,510
  • 29
  • 395
  • 339
DEVISRI S
  • 9
  • 1

0 Answers0