노드js
Axios default Config 내용
세객
2019. 12. 8. 20:29
Axios default Config
{
"transformRequest":[null],
"transformResponse":[null],
"timeout":0,
"xsrfCookieName":"XSRF-TOKEN",
"xsrfHeaderName":"X-XSRF-TOKEN",
"maxContentLength":-1,
"headers":{
"common":{
"Accept":"application/json, text/plain, */*"
},
"delete":{},
"get":{},
"head":{},
"post":{
"Content-Type":"application/x-www-form-urlencoded"
},
"put":{
"Content-Type":"application/x-www-form-urlencoded"
},
"patch":{
"Content-Type":"application/x-www-form-urlencoded"}
}
}
- Axios default 의 Config 내부 파일인데 json 으로 뽑다보니 transformRequest, transfromResponse 객체는 함수인데 null 로 표시되어있다. 링크
- default config 객체에 새로운 axios.create(A) 를 생성할 경우 default config 객체와 A config 객체를 merge 한다.
- merge 하면 사용자가 임의로 넣은 config 객체가 우선권으로 적용된다.
- http 요청을 사용할 때는 get(url, config) 처럼 오는데 뒤에 config 는 자신이 axios.create(A) 를 할때 사용한 A 객체보다 우선권이 낮다.