알쓸전컴(알아두면 쓸모있는 전자 컴퓨터)

axios post 에 params 데이터 보내기 본문

Web /Vue js tip

axios post 에 params 데이터 보내기

백곳 2018. 3. 3. 10:28

post 에 params 데이터 보내기 


Get 방식의 경우에는 


axios.get('/user', {
    params: {
      ID: 12345
    }
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });
  

위와 같이 보내면 되지만 


Post 는 안됩니다. 


npm  install url-search-params-polyfill  --save 로 설치를 하고 이유는 IE 11 을 커버 하기 위해서 입니다. 


<script>
import 'url-search-params-polyfill';


을 추가 해 줍니다. 


var params = new URLSearchParams();
params.append('doc_number', this.no);
params.append('doc_password', this.doc_password);
axios.post('/W_Server/suggestion_board_delete'
,params)
.then((Resopnse) => {

}).catch((ex)=>{
console.log(ex);

})



위와 같이 보내면 parmas 을 보낼수 있습니다. 



Comments