Skip to content

Commit 61cad66

Browse files
authored
Merge pull request #395 from vultr/issue-394
#394 adds missing header to POST requests
2 parents 04e7f4b + 00c60d1 commit 61cad66

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/util.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ exports.makeApiRequest = (config, endpoint, parameters) => {
1010
}
1111

1212
if (parameters !== undefined) {
13-
const userParams = Object.keys(parameters).map((key) => key + '=' + encodeURIComponent(parameters[key])).join('&')
13+
const userParams = Object.keys(parameters)
14+
.map((key) => key + '=' + encodeURIComponent(parameters[key]))
15+
.join('&')
1416

1517
if (endpoint.requestType === 'POST') {
1618
options.body = userParams
19+
options.headers['Content-Type'] = 'application/x-www-form-urlencoded'
1720
} else if (endpoint.requestType === 'GET') {
1821
fetchUrl = `${fetchUrl}?${userParams}`
1922
}

0 commit comments

Comments
 (0)