File tree 1 file changed +10
-11
lines changed
packages-exp/auth-exp/src/api
1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change 15
15
* limitations under the License.
16
16
*/
17
17
18
- import { FirebaseError } from '@firebase/util' ;
18
+ import { FirebaseError , querystring } from '@firebase/util' ;
19
19
import { AuthErrorCode , AUTH_ERROR_FACTORY } from '../core/errors' ;
20
20
import { Auth } from '../model/auth' ;
21
21
import { IdTokenResponse } from '../model/id_token' ;
@@ -65,28 +65,27 @@ export async function performApiRequest<T, V>(
65
65
const errorMap = { ...SERVER_ERROR_MAP , ...customErrorMap } ;
66
66
try {
67
67
let body = { } ;
68
- const params : { [ key : string ] : string } = {
69
- key : auth . config . apiKey
70
- } ;
68
+ let params = { } ;
71
69
if ( request ) {
72
70
if ( method === HttpMethod . GET ) {
73
- Object . assign ( params , request ) ;
71
+ params = request ;
74
72
} else {
75
73
body = {
76
74
body : JSON . stringify ( request )
77
75
} ;
78
76
}
79
77
}
80
78
81
- const queryString = Object . keys ( params )
82
- . map ( key => {
83
- return `${ encodeURIComponent ( key ) } =${ encodeURIComponent ( params [ key ] ) } ` ;
84
- } )
85
- . join ( '&' ) ;
79
+ const query = querystring (
80
+ {
81
+ key : auth . config . apiKey ,
82
+ ...params
83
+ }
84
+ ) . slice ( 1 )
86
85
87
86
const response : Response = await Promise . race < Promise < Response > > ( [
88
87
fetch (
89
- `${ auth . config . apiScheme } ://${ auth . config . apiHost } ${ path } ?${ queryString } ` ,
88
+ `${ auth . config . apiScheme } ://${ auth . config . apiHost } ${ path } ?${ query } ` ,
90
89
{
91
90
method,
92
91
headers : {
You can’t perform that action at this time.
0 commit comments