Unexpected token < in JSON at position 0 for author field

<%= @topic_view.topic.title %>
<%= @topic_view.topic.average_rating %> <%= @topic_view.topic.posts.count { |p| !!p.custom_fields['rating'] } %>

I am trying to add the author field, but when I check the solution, it responds with Unexpected token < in JSON at position 0.
I think it might be some thing with the link.

A bit more context may be extremely useful to help you, also if it happens in a project, a codepen would be extremely useful

I use glicth…


idk if this works

You need to submit the link to the Glitch page not the JSON file. That is, submit the page you get when clicking the Show button up top.

thank you very much for the help!

You are getting HTML instead of JSON as a response (this normally occurs when you hit an error page). This is what the error message means, the start of an HTML document looks like:

<!doctype html>
<html .................

And the character at position 0 is <

1 Like

I get an error whenever I try to use the show button. Is there another way?

What type of error are you getting?

Are you sure you don’t have errors in the code? If you open the console on Glitch (Ctrl + Shift + L) what do you see?

It is the error that is the title of this post if i try to submit the main page. If I click show and use the app url, the error is

// running tests
Timeout has occurred
// tests completed

I don’t think there is any issue in the code. The console gives no indication of a problem.

I’ve been combing the forums and found a plethora of posts about this with people coming up with various ways they got it to work. None have worked for me so far.

The Unexpected token < in JSON at position 0 is from submitting the json file instead of the full page link. The Timeout has occurred is pointing to some error in your code. Please post a link to your Glitch project.

That is a link to the package.json file. Please post the link to your project URL.

Edit:

This is the project page

https://glitch.com/edit/#!/ebony-weaver

This is the full page URL that you use to submit.
https://ebony-weaver.glitch.me

@mcrombie Try this. Make sure you are logged into Glitch (try using a Github login if you have not) then make sure you are using the correct starter link.

2 Likes

By the way, what challenge are you working on, you didn’t say?

This is for the author field challenge

OK so it is the Managing Packages with npm Challenges. Then you have to make sure you are using the correct starter project. Use the link I gave in my post above.

This worked! I am not sure why. Was it logging in through gitHub?

I think you just had the wrong starter project, but using a Github login seems to help to make sure the starter project gets imported correctly.

Anyway, good you fixed it. Just remember to always use the full page link for the submit.

1 Like