Vue-client project get request to pass object parameters

Scenes:

        Call the backend interface to obtain list data, and the interface is a get request. The get request parameter is generally xx=yy, but the new interface backend requires an object and attribute parameter.

The backend says that the parameters are passed as:

        url?name=xxx&tel=xxx&gf.name=xxx

The code I wrote at the beginning is as follows, and the backend will report an error:

var param ={name:'张三',tel:'111',gf:{name:'李四'}};

const {code,data,msg} = await getDataList(param )

 The displayed request link will become: url?name=xxx&tel=xxx& gf=name=xxx   

Finally changed the code, as follows:

var param ={name:'张三',tel:'111'};
param['gf.name'] = '李四';

const {code,data,msg} = await getDataList(param )

The key code is: param['gf.name'] = 'Lisi';

The request link presented is: url?name=xxx&tel=xxx &gf.name=xxx

In this way, the backend can receive all parameters.

Guess you like

Origin blog.csdn.net/ss_Tina/article/details/131011610