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

POST request error - SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data #2

Open
Flexusaurs opened this issue Jan 21, 2022 · 2 comments

Comments

@Flexusaurs
Copy link

Flexusaurs commented Jan 21, 2022

POST ERROR WHILE ADDING DATA FROM REST CLIENTS

I first tried to re-write this whole project from scratch as an exercise, just trying do dip my feet into Next and React.
In the beginning, I thought it was something wrong on my end and re factored the whole project down to some packages (worst idea),
then deleting my version and doing a clean git clone of the project to my local directory.

I tried to do a clean run, just updated my .env file.

The error I got on the page itself was as follows:

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

I also got another error that may be related:

TypeError: Invalid protocol

Steps to recreate

  • create a local separate directory
  • cd "insert-your-directory"
  • git clone https://github.com/fireship-io/redis-nextjs-fulltext-search.git .
  • npm run dev
@NoahMLoomis
Copy link

NoahMLoomis commented Jan 25, 2022

I'm running into the exact same problem... I feel like it's a small fix that I don't know just because I'm new to Redis

The problem seems to be happening with the connection to the client in redis.js.

    console.log("Before")
    await client.open(process.env.REDIS_URL);
    console.log("After")

The "Before is printing out but not after.

I checked and my env REDIS_URL is coming through as it's supposed to.

I'll try looking through the video again to see if I missed anything with my connection to the redis DB

@NoahMLoomis
Copy link

NoahMLoomis commented Jan 25, 2022

@Flexusaurs Figured it out, you probably have the same issue

When adding the REDIS_URL to your .env.local, i accidentally just copy and pasted the public endpoint, instead of doing the format that Jeff says to use.

The format to use is redis://default:HOST:PORT

For me it was
REDIS_URL=redis://default:ExKnoJSYIRo3kY0v9PhjBOQZ8DsFhYh1@redis-14847.c245.us-east-1-3.ec2.cloud.redislabs.com:14847

Here's the spot where he talks about it:
https://youtu.be/DOIWQddRD5M?t=300

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