백엔드로 데이터를 전송하는 명령어
조회 : await this.axios.get(url, {headers:headers});
추가 : await this.axios.post(url, body, {headers:headers});
수정 : await this.axios.put(url, body, {headers:headers});
삭제 : await this.axios.delete(url, {headers:headers, data:{ }});
data(){
return{
username : '',
usermail : '',
dom : '',
token : sessionStorage.getItem("TOKEN"),
}
},
// 백엔드
const url = '주소'
const headers = {
"Content-Type":"application/json",
"TOKEN" : this.token
};
// headers가 먼저 들어가기 떄문에 검증 후 토큰의 유효성이 검증되지 않으면
// body를 궂이 받을 필요가 없기떄문에 headers에 토큰을 넣어서 보냄
const body = {
username : this.username,
usermail : this.usermail+"@"+this.dom
}
const response = await this.axios.put(url, body, {headers:headers});
console.log(response);