File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -176,7 +176,11 @@ export default class IPData {
176176
177177 try {
178178 const response = await axios . get ( url , { params } ) ;
179- const data = { ...response . data , status : response . status } ;
179+ let data = { ...response . data , status : response . status } ;
180+
181+ if ( selectField ) {
182+ data = { [ selectField ] : response . data , status : response . status } ;
183+ }
180184
181185 if ( ( ! selectField || ! fields ) && this . useCache ) {
182186 cache . set ( ip || DEFAULT_IP , data ) ;
Original file line number Diff line number Diff line change @@ -69,10 +69,10 @@ describe('lookup()', () => {
6969 await expect ( ipdata . lookup ( null , field ) ) . rejects . toThrowError ( `${ field } is not a valid field.` ) ;
7070 } ) ;
7171
72- it ( 'should return a response with only the field' , async ( ) => {
72+ it . only ( 'should return a response with only the field' , async ( ) => {
7373 const field = 'is_eu' ;
7474 const info = await ipdata . lookup ( null , field ) ;
75- expect ( info ) . toHaveProperty ( 'select_field' , false ) ;
75+ expect ( info ) . toHaveProperty ( field , false ) ;
7676 expect ( info ) . toHaveProperty ( 'status' ) ;
7777 } ) ;
7878 } ) ;
You can’t perform that action at this time.
0 commit comments