Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error parsing JSON Feed #18

Closed
JS1010111 opened this issue Dec 16, 2017 · 4 comments
Closed

Error parsing JSON Feed #18

JS1010111 opened this issue Dec 16, 2017 · 4 comments

Comments

@JS1010111
Copy link

The following error is occurring when trying to parse a JSON Feed.

Failing tested JSON Feeds:
https://daringfireball.net/feeds/json
http://inessential.com/feed.json

Error:

Exception has occurred: Error
TypeError: Cannot set property 'type' of undefined
    at CStream.parser.done (e:\Projects\ely\node_modules\feedme\lib\jsonfeedparser.js:140:15)
    at self.children.forEach (e:\Projects\ely\node_modules\eventyoshi\lib\index.js:255:28)
    at Map.forEach (native)
    at EventYoshi.Array.slice.call.forEach.self.(anonymous function) [as done] (e:\Projects\ely\node_modules\eventyoshi\lib\index.js:253:23)
    at EventYoshi.<anonymous> (e:\Projects\ely\feedparser.js:15:27)
    at emitNone (events.js:86:13)
    at EventYoshi.emit (events.js:185:7)
    at CStream.wrapper.__wrappers.(anonymous function) (e:\Projects\ely\node_modules\eventyoshi\lib\index.js:105:14)
    at emitNone (events.js:86:13)
    at CStream.emit (events.js:185:7)

This is the e:\Projects\ely\feedparser.js:

var FeedMe = require('feedme');
var Request = require('request');
var URL = require('url');

module.exports = function (url, cb) {

    var feedme = new FeedMe(true);

    feedme.on('error', function (error) {
        return cb(415);
    });

    feedme.on('end', function () {
        var feed = feedme.done();
        return cb(null, feed);
    });

    var options = {
        encoding: null,
        gzip: true,
        timeout: 5000,
        url: URL.parse(url)
    };

    Request.get(options, function(error, response, body) {
        if (error) {
            return cb(response.statusCode);
        } else {
            feedme.write(body);
            feedme.end();
        }
    })

};
@fent
Copy link
Owner

fent commented Dec 16, 2017

Ah, these feeds are using a new version of JSON feeds that was just released this year: https://jsonfeed.org/version/1

When I created this, that didn't exist. The JSON feed is instead an Atom feed, but in JSON format. I'll have to update this to use the new format, so I'll keep this opened.

@TheScree
Copy link

TheScree commented Feb 20, 2018

@fent Just as an FYI, Wordpress has a baked in JSON feed for all self-hosted installs. This is a MAJOR potential consumer of this. This not working is holding me back from using this library.

I ran into this issue attempting to consume a Wordpress JSON feed. As the owner of the Wordpress install, I can tell you that it's running the latest version as of today's date.

https://stealthed.blog/wp-json/

@fent fent closed this as completed in da0ff3d Feb 25, 2018
@JS1010111
Copy link
Author

Thank you, @fent !

@TheScree
Copy link

Mucho Gracias ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants