Skip to content

Commit e71f19b

Browse files
jfr3000Khaledgarbaya
authored andcommitted
feat: Add raw request method to client (#118)
1 parent 0f36742 commit e71f19b

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

lib/create-contentful-api.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,34 @@ export default function createClientApi ({ http }) {
141141
.then((response) => wrapOrganizationCollection(http, response.data), errorHandler)
142142
}
143143

144+
/**
145+
* Make a custom request to the Contentful management API's /spaces endpoint
146+
* @memberof ContentfulClientAPI
147+
* @param {Object} opts - axios request options (https://github.com/mzabriskie/axios)
148+
* @return {Promise<Object>} Promise for the response data
149+
* @example
150+
* const contentful = require('contentful-management')
151+
*
152+
* const client = contentful.createClient({
153+
* accessToken: '<content_management_api_key>'
154+
* })
155+
*
156+
* client.rawRequest({
157+
* method: 'GET',
158+
* url: '/custom/path'
159+
* })
160+
* .then((responseData) => console.log(responseData))
161+
* .catch(console.error)
162+
*/
163+
function rawRequest (opts) {
164+
return http(opts).then((response) => response.data, errorHandler)
165+
}
166+
144167
return {
145168
getSpaces: getSpaces,
146169
getSpace: getSpace,
147170
createSpace: createSpace,
148-
getOrganizations: getOrganizations
171+
getOrganizations: getOrganizations,
172+
rawRequest: rawRequest
149173
}
150174
}

0 commit comments

Comments
 (0)