File tree 1 file changed +7
-4
lines changed
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -378,10 +378,13 @@ class Scrappey {
378
378
379
379
// If Users forget to give that content-type but data is json, it will be added automatically.
380
380
if ( this . isJSON ( options . postData ) ) {
381
- let jsonpostData = JSON . parse ( options . postData )
382
-
383
- if ( ! Object . keys ( jsonpostData ) . map ( key => key . toLowerCase ( ) ) . includes ( "content-type" ) ) {
384
- options . postData = JSON . stringify ( { ...jsonpostData , "content-type" : "application/json" } )
381
+ let headerKeys = Object . keys ( options ?. customHeaders || { } ) ;
382
+ if ( typeof options ?. customHeaders === "undefined" || headerKeys . length === 0 ) {
383
+ options . customHeaders = { "content-type" : "application/json" } ;
384
+ } else if (
385
+ typeof options . customHeaders === "object" &&
386
+ ! headerKeys . map ( key => key . toLowerCase ( ) ) . includes ( "content-type" ) ) {
387
+ options . customHeaders = { ...options . customHeaders , "content-type" : "application/json" } ;
385
388
}
386
389
}
387
390
You can’t perform that action at this time.
0 commit comments