P粉6681137682023-09-04 10:33:29
As Quentin pointed out in the comments, the axios documentation has one required parameter (url) and one optional parameter (config). Your code is passed three parameters, so the error is accurate, and the three-parameter get
call is not doing what you'd expect in JS or TS.
However, the config
parameter accepts a key named params
, which is most likely the intended location of your params
. You can use the Javascript abbreviation just use the name params
instead of params: params
. This means your fix is simply to move the params
to the inside (braces) of the object initializer.
If this code worked before, the params
may have been in the object initializer on the same line as the URL, but were mistakenly moved outside the URL.
async getPartnerReferences(params: any) { if (!params) return; const { data } = await axios.get(`your.url`, { params, // this is now a part of the config object withCredentials: true }); return data.data; }