I found that many projects use "querystring parsing and stringifying library" to serialize the data to be transmitted in post requests, such as qs.
//POST傳參序列化(添加請(qǐng)求攔截器)
axios.interceptors.request.use((config) => {
//在發(fā)送請(qǐng)求之前做某件事
if(config.method === 'post'){
config.data = qs.stringify(config.data);
}
return config;
},(error) =>{
_.toast("錯(cuò)誤的傳參", 'fail');
return Promise.reject(error);
});
There is a sentence in the introduction in qs: "A querystring parsing and stringifying library with some added security." May I ask where the safety is reflected?
歡迎選擇我的課程,讓我們一起見(jiàn)證您的進(jìn)步~~
Look at the test cases of qs and you will know https://github.com/ljharb/qs/...
The security value is that the data you construct is legal.
The comment was written in the wrong place qs Is this library mainly used to detect whether the data is legal? Because if I used jQuery and axios before, I could still send ajax requests even if I didn’t add the qs library.