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传参序列化(添加请求拦截器)
axios.interceptors.request.use((config) => {
//在发送请求之前做某件事
if(config.method === 'post'){
config.data = qs.stringify(config.data);
}
return config;
},(error) =>{
_.toast("错误的传参", '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?
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.