Skip to content

Некорректное чтение или преобразования #9

Description

@alekseikorobov

long-poll-chat

https://github.com/iliakan/nodejs-screencast/blob/master/long-poll-chat/server.js#L23
в строке где body +=req.read();
req.read() последним значением возвращает null, что приводит к строке, например:
{"message":"привет"}null
и соответственно в строке body = JSON.parse(body); появляется ошибка.
Для того чтобы json был валидным
нужно сделать проверку на null
var req_read = req.read();
if(req_read != null) body += req_read;

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions