import joinUrl from '../../../../shared/utils/joinUrl' ; import environment from '../../../../environment' ; import { fetchWithoutToken } from '../../../../shared/utils/api/api' ; import type { List } from './types' ; param queryParams param receiveFields export const getNummeraanduidingByAddress = ( queryParams , receiveFields ? ) : Promise < List | null > => { const paramsString = queryParams . substr ( queryParams . indexOf ( '?' ) ) ; const searchParams = new URLSearchParams ( paramsString ) ; if ( ! searchParams . get ( 'postcode' ) || ! searchParams . get ( 'huisnummer' ) ) { return Promise . resolve ( null ) ; } if ( receiveFields ) { searchParams . append ( '_fields' , receiveFields ) ; } const url = joinUrl ( [ environment . API_ROOT , 'v1/bag/nummeraanduiding' ] ) ; return fetchWithoutToken ( `${ url }?${ searchParams . toString ( ) }` ) ; } ;