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

Unrecognised token '<' error #12

Open
rahulbhankar786 opened this issue Dec 22, 2017 · 1 comment
Open

Unrecognised token '<' error #12

rahulbhankar786 opened this issue Dec 22, 2017 · 1 comment

Comments

@rahulbhankar786
Copy link

rahulbhankar786 commented Dec 22, 2017

{ [SyntaxError: JSON Parse error: Unrecognized token '<']
line: 10658,
column: 14,
sourceURL: 'http://11.0.8.2:8081/index.bundle?platform=android&dev=true&minify=false' }

url: http://www.recipepuppy.com/recipes/findByIngredients//?ingredients=bacon%2C%20cucumber%2C%20banana&fillIngredients=false&limitLicense=false&number=20&ranking=1 giving me 404 page not found

image

@KRUBERLICK
Copy link

KRUBERLICK commented Mar 1, 2018

@rahulbhankar786, that's because the api path and param names have changed.
Make the following changes to api.js and recipes.js actions:

api.js:

static xhr(route, params, verb) {
  const host = 'http://www.recipepuppy.com/api'
  const url = `${host}${route}`
  let options = Object.assign({ method: verb }, params ? { body: JSON.stringify(params) } : null );
  options.headers = Api.headers()
  return fetch(url, options).then( resp => {
    let json = resp.json();
    if (resp.ok) {
      return json
    }
    return json.then(err => {throw err});
  }).then( json => json.results );
}

recipes.js actions:

export function fetchRecipes(ingredients) {
  return (dispatch, getState) => {
    const params = [
      `i=${encodeURIComponent(ingredients)}`,
    ].join('&');
    return Api.get(`/?${params}`)
      .then(resp => {
        console.log(resp);
      })
      .catch(err => {
        console.log(err);
      })
  };
}

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

No branches or pull requests

2 participants