File tree 1 file changed +14
-4
lines changed
1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -187,16 +187,26 @@ export default class WooCommerceRestApi {
187
187
_request ( method , endpoint , data , params = { } ) {
188
188
const url = this . _getUrl ( endpoint , params ) ;
189
189
190
+ const headers = {
191
+ Accept : "application/json"
192
+ } ;
193
+ // only set "User-Agent" in node environment
194
+ // the checking method is identical to upstream axios
195
+ if (
196
+ typeof process !== "undefined" &&
197
+ Object . prototype . toString . call ( process ) === "[object process]"
198
+ ) {
199
+ headers [ "User-Agent" ] =
200
+ "WooCommerce REST API - JS Client/" + this . classVersion ;
201
+ }
202
+
190
203
let options = {
191
204
url : url ,
192
205
method : method ,
193
206
responseEncoding : this . encoding ,
194
207
timeout : this . timeout ,
195
208
responseType : "json" ,
196
- headers : {
197
- "User-Agent" : "WooCommerce REST API - JS Client/" + this . classVersion ,
198
- Accept : "application/json"
199
- }
209
+ headers
200
210
} ;
201
211
202
212
if ( this . isHttps ) {
You can’t perform that action at this time.
0 commit comments