1
1
import Adapter from '@pollyjs/adapter' ;
2
2
import serializeHeaders from './utils/serialize-headers' ;
3
3
4
- const nativeFetch = self . fetch ;
4
+ const nativeFetch = global . fetch ;
5
5
const { defineProperty } = Object ;
6
6
7
7
export default class FetchAdapter extends Adapter {
8
8
onConnect ( ) {
9
9
this . assert ( 'Fetch global not found.' , nativeFetch ) ;
10
10
this . assert (
11
11
'Running concurrent fetch adapters is unsupported, stop any running Polly instances.' ,
12
- self . fetch === nativeFetch
12
+ global . fetch === nativeFetch
13
13
) ;
14
14
15
15
this . native = nativeFetch ;
16
- self . fetch = ( url , options = { } ) =>
16
+ global . fetch = ( url , options = { } ) =>
17
17
this . handleRequest ( {
18
18
url,
19
19
method : options . method || 'GET' ,
@@ -24,7 +24,7 @@ export default class FetchAdapter extends Adapter {
24
24
}
25
25
26
26
onDisconnect ( ) {
27
- self . fetch = nativeFetch ;
27
+ global . fetch = nativeFetch ;
28
28
}
29
29
30
30
async onRecord ( pollyRequest ) {
@@ -50,7 +50,7 @@ export default class FetchAdapter extends Adapter {
50
50
async onPassthrough ( pollyRequest ) {
51
51
const [ , options ] = pollyRequest . requestArguments ;
52
52
53
- const response = await this . native . apply ( self , [
53
+ const response = await this . native . apply ( global , [
54
54
pollyRequest . url ,
55
55
{
56
56
...options ,
0 commit comments