contentful
Advanced tools
Comparing version 0.0.6 to 0.0.7
{ | ||
"name": "contentful", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"main": "dist/contentful.min.js", | ||
@@ -5,0 +5,0 @@ "ignore": [ |
23
index.js
@@ -20,3 +20,9 @@ 'use strict'; | ||
request: function(path) { | ||
request: function(path, options) { | ||
if (!options) options = {}; | ||
if (!options.headers) options.headers = {}; | ||
if (!options.query) options.query = {}; | ||
options.headers['Content-Type'] = 'application/vnd.contentful.v1+json'; | ||
options.query.access_token = this.options.accessToken; | ||
var uri = [ | ||
@@ -30,12 +36,7 @@ this.options.secure ? 'https' : 'http', | ||
this.options.space, | ||
path | ||
path, | ||
'?', | ||
querystring.stringify(options.query) | ||
].join(''); | ||
var options = { | ||
headers: { | ||
Authorization: 'Bearer ' + this.options.accessToken, | ||
'Content-Type': 'application/vnd.contentful.v1+json' | ||
} | ||
}; | ||
var promise = new Promise(); | ||
@@ -62,3 +63,3 @@ var request = questor(uri, options); | ||
var promise = new Promise(); | ||
var request = this.request('/content_types' + (object ? '?' + query.toQueryString() : '')); | ||
var request = this.request('/content_types', {query: query}); | ||
request.map(_.partial(SearchResult.parse, ContentType)) | ||
@@ -81,3 +82,3 @@ .map(_.bound(promise, 'resolve')); | ||
var promise = new Promise(); | ||
var request = this.request('/entries' + (object ? '?' + query.toQueryString() : '')); | ||
var request = this.request('/entries', {query: query}); | ||
request.map(_.partial(SearchResult.parse, Entry)) | ||
@@ -84,0 +85,0 @@ .map(_.bound(promise, 'resolve')); |
{ | ||
"name": "contentful", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Client for Contentful's Content Delivery API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# contentful.js | ||
Javascript client for [Contentful's](https://www.contentful.com) Content Delivery API: | ||
[Documentation](https://www.contentful.com/developers/documentation/content-delivery-api) | ||
## Install | ||
In node, using [npm](http://npmjs.org): | ||
``` sh | ||
@@ -9,5 +16,18 @@ npm install contentful | ||
In a browser, using [bower](http://bower.io): | ||
``` sh | ||
bower install contentful | ||
# After installing, add this as a script tag: | ||
# <script src="components/contentful/dist/contentful.min.js"></script> | ||
``` | ||
Note: The next minor version release of `dist/contentful.min.js` will | ||
be much smaller. Please use bower to keep your JS dependencies up to | ||
date and get the newest version right when it's ready! | ||
## Usage | ||
``` js | ||
// Don't require if you've already included contentful as a script tag | ||
var contentful = require('contentful'); | ||
@@ -17,6 +37,6 @@ | ||
// ID of Space | ||
space: '...', | ||
space: 'cfexampleapi', | ||
// A valid access token within the Space | ||
accessToken: '...', | ||
accessToken: 'b4c0n73n7fu1', | ||
@@ -27,11 +47,17 @@ // Enable or disable SSL. Enabled by default. | ||
var log = console.log.bind(console); // wat | ||
// Get Space | ||
client.space().then(console.log, console.log); | ||
client.space().then(log, log); | ||
// Get all Entries | ||
client.entries().then(console.log, console.log); | ||
client.entries().then(log, log); | ||
``` | ||
For now, please check out the | ||
[Content Delivey API's documentation](https://www.contentful.com/developers/documentation/content-delivery-api) | ||
[Content Delivery API documentation](https://www.contentful.com/developers/documentation/content-delivery-api) | ||
to learn how the API and the JavaScript client work. | ||
## License | ||
MIT |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
11866
61
10
605338
11