Just some background, I got my front end certification before FCC made the shift to the new systems so I’m trying to do the API certification directly and skipping the front end and Javascript sections. So if this is answered in those sections that’s why I don’t know how to use the new system. That said, I’m trying to do the problem “Managing Packages with Npm - How to Use package.json, the Core of Any Node.js Project or npm Package” but when I try to use the url https://glitch.com/edit/#!/daffy-catshark to share my code using the link that Glitch provided and paste it into the solution line, I get this result:
// running test
Unexpected token < in JSON at position 0
// tests completed
This is after I placed the “author” line in the package.JSON file. Seeing that it didn’t work, I tried removing the “author” line and testing the original and it still ended up with the same error. I’ve never had to use Glitch before so I’m a bit lost and I can’t move forward without it.
It looks like you’re using the url for the development(editor), use the app url. Click on the share button upper left corner and copy the link for sharing your App, paste in the solution.
I concur. This threw me as well. Note that I jump around, and jumped into some express project stuff calling for the use of Glitch, so I was sorta presuming I just missed/skipped the section of curriculum that explains “how to use Glitch for coding and how to share progress and solutions to fcc exercises…”
But would be wise to provide a jump to docs that explain this wherever relevant.
I’d like to share with you my 2cents after struggling with this issue and passed it successfully.
You can pass this test without using Glitch services at all. You only need to be sure that you are using res.json() properly and you are not rendering HTML or invalid JSON characters.
Here’s my solution:
let jsonTpl= `{
"author": "John Doe",
"description": "freeCodeCamp - Apis And Microservices Certification (300 hours)"
}`;
app.get('/_api/package.json',function(req,res){
res.json(jsonTpl);
res.end();
});
Hope it helps you!
PS: Why should we use Glitch? it’s an unnecessary pain.
Hi, my apologies - I just read entire thread and think I’m caught up. If you’re working in the Info Sec challenges and are currently trying to pass the Content Security Policy, which can be tricky. Providing your code is right, try clearing your browser cache and cookies. https://helmetjs.github.io/docs/csp/