Skip to content

Commit 792fd5f

Browse files
committed
Bug fixes vultr#434
1 parent 5d9874e commit 792fd5f

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

src/api/dns.js

+5
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ exports.createRecord = {
179179
requestType: 'POST',
180180
apiKeyRequired: true,
181181
parameters: {
182+
'dns-domain': {
183+
type: 'string',
184+
path: true,
185+
required: true
186+
},
182187
name: {
183188
type: 'string',
184189
required: true

src/util.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@ exports.makeApiRequest = (config, endpoint, userParameters) => {
1212
if (userParameters !== undefined) {
1313
const { requestType, parameters } = endpoint
1414

15+
// All methods may have path parameters
16+
const pathParams = Object.keys(userParameters).filter(
17+
(key) => parameters[key].path
18+
)
19+
20+
if (pathParams.length) {
21+
pathParams.forEach((param) => {
22+
// Ex. '/bare-metals/{baremetal-id}/ipv4' becomes '/bare-metals/123456/ipv4'
23+
fetchUrl = fetchUrl.replace(`{${param}}`, userParameters[param])
24+
})
25+
}
26+
1527
if (requestType === 'POST') {
1628
// POST requests will just send all data as JSON to the endpoint
1729
options.body = JSON.stringify(userParameters)
1830
options.headers['Content-Type'] = 'application/json'
1931
} else {
20-
// GET, DELETE, PATCH, and PUT may have path parameters
21-
const pathParams = Object.keys(userParameters).filter(
22-
(key) => parameters[key].path
23-
)
24-
25-
if (pathParams.length) {
26-
pathParams.forEach((param) => {
27-
// Ex. '/bare-metals/{baremetal-id}/ipv4' becomes '/bare-metals/123456/ipv4'
28-
fetchUrl = fetchUrl.replace(`{${param}}`, userParameters[param])
29-
})
30-
}
31-
3232
if (requestType === 'GET' || requestType === 'DELETE') {
3333
// GET and DELETE requests may have path parameters as well as query parameters
3434
const queryParams = Object.keys(userParameters)

0 commit comments

Comments
 (0)