fix: JSON.stringify for filter
This commit is contained in:
		
							parent
							
								
									eb501e3461
								
							
						
					
					
						commit
						2fd4e2fa61
					
				@ -1,3 +1,4 @@
 | 
			
		||||
import { stringify } from 'querystring';
 | 
			
		||||
import { request } from 'umi';
 | 
			
		||||
 | 
			
		||||
interface ActionParams {
 | 
			
		||||
@ -27,9 +28,11 @@ class ApiClient {
 | 
			
		||||
    const proxy: any = new Proxy({}, {
 | 
			
		||||
      get(target, method, receiver) {
 | 
			
		||||
        return (params: ActionParams = {}) => {
 | 
			
		||||
          const { associatedKey, resourceKey, ...restParams } = params;
 | 
			
		||||
          const { associatedKey, resourceKey, filter, ...restParams } = params;
 | 
			
		||||
          let url = `/${name}`;
 | 
			
		||||
          let options: any = {};
 | 
			
		||||
          let options: any = {
 | 
			
		||||
            params: {},
 | 
			
		||||
          };
 | 
			
		||||
          if (['list', 'get'].indexOf(method as string) !== -1) {
 | 
			
		||||
            options.method = 'get';
 | 
			
		||||
            options.params = restParams;
 | 
			
		||||
@ -45,6 +48,9 @@ class ApiClient {
 | 
			
		||||
          if (resourceKey) {
 | 
			
		||||
            url += `/${resourceKey}`;
 | 
			
		||||
          }
 | 
			
		||||
          if (filter) {
 | 
			
		||||
            options.params['filter'] = JSON.stringify(filter);
 | 
			
		||||
          }
 | 
			
		||||
          console.log({url, params});
 | 
			
		||||
          return request(url, options);
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user