Put request with simple string as request body

前端 未结 8 704
谎友^
谎友^ 2020-12-24 13:52

When I execute the following code from my browser the server gives me 400 and complains that the request body is missing. Anybody got a clue about how I can pass a simple st

8条回答
  •  无人及你
    2020-12-24 14:42

    This worked for me:

    export function modalSave(name,id){
      console.log('modalChanges action ' + name+id);  
    
      return {
        type: 'EDIT',
        payload: new Promise((resolve, reject) => {
          const value = {
            Name: name,
            ID: id,
          } 
    
          axios({
            method: 'put',
            url: 'http://localhost:53203/api/values',
            data: value,
            config: { headers: {'Content-Type': 'multipart/form-data' }}
          })
           .then(function (response) {
             if (response.status === 200) {
               console.log("Update Success");
               resolve();
             }
           })
           .catch(function (response) {
             console.log(response);
             resolve();
           });
        })
      };
    }
    

提交回复
热议问题