@@ -71,7 +71,7 @@ public virtual void Initialize()
71
71
{
72
72
_httpQueryClient . BaseAddress = new Uri ( $ "https://{ WebUtility . UrlEncode ( _options . ProjectId ) } .api.sanity.io/{ _options . ApiVersion } /") ;
73
73
}
74
- if ( ! string . IsNullOrEmpty ( _options . Token ) && ! _options . UseCdn )
74
+ if ( ! string . IsNullOrEmpty ( _options . Token ) )
75
75
{
76
76
_httpQueryClient . DefaultRequestHeaders . Authorization = new AuthenticationHeaderValue ( "Bearer" , _options . Token ) ;
77
77
}
@@ -92,7 +92,6 @@ public virtual void Initialize()
92
92
_httpQueryClient . DefaultRequestHeaders . Authorization = new AuthenticationHeaderValue ( "Bearer" , _options . Token ) ;
93
93
}
94
94
}
95
-
96
95
}
97
96
98
97
public virtual async Task < SanityQueryResponse < TResult > > FetchAsync < TResult > ( string query , object parameters = null , CancellationToken cancellationToken = default )
@@ -106,23 +105,8 @@ public virtual async Task<SanityQueryResponse<TResult>> FetchAsync<TResult>(stri
106
105
Query = query ,
107
106
Params = parameters
108
107
} ;
109
- HttpResponseMessage response = null ;
110
- if ( _options . UseCdn )
111
- {
112
- // CDN only supports GET requests
113
- var url = $ "data/query/{ WebUtility . UrlEncode ( _options . Dataset ) } ?query={ WebUtility . UrlEncode ( query ?? "" ) } ";
114
- if ( parameters != null )
115
- {
116
- //TODO: Add support for parameters
117
- }
118
- response = await _httpQueryClient . GetAsync ( url , cancellationToken ) ;
119
- }
120
- else
121
- {
122
- // Preferred method is POST
123
- var json = new StringContent ( JsonConvert . SerializeObject ( oQuery , Formatting . None , SerializerSettings ) , Encoding . UTF8 , "application/json" ) ;
124
- response = await _httpQueryClient . PostAsync ( $ "data/query/{ WebUtility . UrlEncode ( _options . Dataset ) } ", json , cancellationToken ) . ConfigureAwait ( false ) ;
125
- }
108
+ var json = new StringContent ( JsonConvert . SerializeObject ( oQuery , Formatting . None , SerializerSettings ) , Encoding . UTF8 , "application/json" ) ;
109
+ HttpResponseMessage response = await _httpQueryClient . PostAsync ( $ "data/query/{ WebUtility . UrlEncode ( _options . Dataset ) } ", json , cancellationToken ) . ConfigureAwait ( false ) ;
126
110
127
111
return await HandleHttpResponseAsync < SanityQueryResponse < TResult > > ( response ) . ConfigureAwait ( false ) ;
128
112
}
0 commit comments