“SyntaxError: token inesperado <no JSON na posição 0”

Em um componente do aplicativo React que lida com feeds de conteúdo do tipo Facebook, estou com um erro:

Feed.js: 94 indefinido "parsererror" "SyntaxError: token inesperado <no JSON na posição 0

Corri para um erro semelhante que acabou por ser um erro de digitação no HTML dentro da função de renderização, mas isso não parece ser o caso aqui.

De maneira mais confusa, revirei o código para uma versão anterior conhecida e ainda estou recebendo o erro.

Feed.js:

import React from 'react';

var ThreadForm = React.createClass({
  getInitialState: function () {
    return {author: '', 
            text: '', 
            included: '',
            victim: ''
            }
  },
  handleAuthorChange: function (e) {
    this.setState({author: e.target.value})
  },
  handleTextChange: function (e) {
    this.setState({text: e.target.value})
  },
  handleIncludedChange: function (e) {
    this.setState({included: e.target.value})
  },
  handleVictimChange: function (e) {
    this.setState({victim: e.target.value})
  },
  handleSubmit: function (e) {
    e.preventDefault()
    var author = this.state.author.trim()
    var text = this.state.text.trim()
    var included = this.state.included.trim()
    var victim = this.state.victim.trim()
    if (!text || !author || !included || !victim) {
      return
    }
    this.props.onThreadSubmit({author: author, 
                                text: text, 
                                included: included,
                                victim: victim
                              })
    this.setState({author: '', 
                  text: '', 
                  included: '',
                  victim: ''
                  })
  },
  render: function () {
    return (
    <form className="threadForm" onSubmit={this.handleSubmit}>
      <input
        type="text"
        placeholder="Your name"
        value={this.state.author}
        onChange={this.handleAuthorChange} />
      <input
        type="text"
        placeholder="Say something..."
        value={this.state.text}
        onChange={this.handleTextChange} />
      <input
        type="text"
        placeholder="Name your victim"
        value={this.state.victim}
        onChange={this.handleVictimChange} />
      <input
        type="text"
        placeholder="Who can see?"
        value={this.state.included}
        onChange={this.handleIncludedChange} />
      <input type="submit" value="Post" />
    </form>
    )
  }
})

var ThreadsBox = React.createClass({
  loadThreadsFromServer: function () {
    $.ajax({
      url: this.props.url,
      dataType: 'json',
      cache: false,
      success: function (data) {
        this.setState({data: data})
      }.bind(this),
      error: function (xhr, status, err) {
        console.error(this.props.url, status, err.toString())
      }.bind(this)
    })
  },
  handleThreadSubmit: function (thread) {
    var threads = this.state.data
    var newThreads = threads.concat([thread])
    this.setState({data: newThreads})
    $.ajax({
      url: this.props.url,
      dataType: 'json',
      type: 'POST',
      data: thread,
      success: function (data) {
        this.setState({data: data})
      }.bind(this),
      error: function (xhr, status, err) {
        this.setState({data: threads})
        console.error(this.props.url, status, err.toString())
      }.bind(this)
    })
  },
  getInitialState: function () {
    return {data: []}
  },
  componentDidMount: function () {
    this.loadThreadsFromServer()
    setInterval(this.loadThreadsFromServer, this.props.pollInterval)
  },
  render: function () {
    return (
    <div className="threadsBox">
      <h1>Feed</h1>
      <div>
        <ThreadForm onThreadSubmit={this.handleThreadSubmit} />
      </div>
    </div>
    )
  }
})

module.exports = ThreadsBox

Nas ferramentas de desenvolvedor do Chrome, o erro parece vir desta função:

 loadThreadsFromServer: function loadThreadsFromServer() {
    $.ajax({
      url: this.props.url,
      dataType: 'json',
      cache: false,
      success: function (data) {
        this.setState({ data: data });
      }.bind(this),
      error: function (xhr, status, err) {
        console.error(this.props.url, status, err.toString());
      }.bind(this)
    });
  },

com a linhaconsole.error(this.props.url, status, err.toString() sublinhado.

Como parece que o erro parece ter algo a ver com a retirada de dados JSON do servidor, tentei iniciar em um banco de dados em branco, mas o erro persiste. O erro parece ser chamado em um loop infinito, presumivelmente, pois o React tenta continuamente se conectar ao servidor e, eventualmente, trava o navegador.

EDITAR:

Verifiquei a resposta do servidor com as ferramentas de desenvolvimento do Chrome e o cliente REST do Chrome, e os dados parecem ser JSON adequados.

EDIT 2:

Parece que, embora o ponto de extremidade da API pretendido esteja realmente retornando os dados e o formato JSON corretos, o React está pesquisandohttp://localhost:3000/?_=1463499798727 em vez do esperadohttp://localhost:3001/api/threads.

Estou executando um servidor de recarga a quente do webpack na porta 3000 com o aplicativo expresso em execução na porta 3001 para retornar os dados de back-end. O que é frustrante aqui é que isso funcionou corretamente na última vez em que trabalhei nele e não consigo encontrar o que poderia ter mudado para quebrá-lo.

questionAnswers(22)

yourAnswerToTheQuestion