Skip to content

Commit 7a80b01

Browse files
authored
docs: Update readme for builder initWith headers losing Content-Type
Adding more documentation and a better default example of mapping to a builder by including the `"Content-Type" : "application/json"` header to avoid content type errors.
1 parent 61cd00d commit 7a80b01

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,14 +908,17 @@ component {
908908
.initWith(
909909
baseUrl = "https://api.github.com",
910910
headers = {
911-
"Authorization" = getColdBox().getSetting( "SWAPI_TOKEN" )
911+
"Content-Type" : "application/json", // If you map to a builder with headers - make sure you set your Content-Type if desired
912+
"Authorization" = getColdBox().getSetting( "SWAPI_TOKEN" )
912913
}
913914
);
914915
}
915916

916917
}
917918
```
918919

920+
Note: If you are mapping a builder and use the `initWith( headers = {... } )`, these headers will overwrite the default headers you get with a HyperRequest so you might see some inconsistencies. A hyperRequest defaults the headers to `"Content-Type" : "application/json"`, so if you want to set a content-type, please include that in your headers struct, like above.
921+
919922
You can also set or change the defaults by either passing the key / value pairs in to the `init` method or by calling the appropriate `HyperRequest` method on the `HyperBuilder.defaults` property.
920923

921924
```js

0 commit comments

Comments
 (0)