Skip to content

Error parsing JSON Feed #18

@JS1010111

Description

@JS1010111

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();
        }
    })

};

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions