I am tasked generating a readme file using node index.js. All my prompts work correctly with user input to create the README.md file except for the badge icon for the user licenses to display. It is showing the URL but not the actual image. here is a sample of one of the lines I have:
const badges = {
'Apache 2.0': 'https://img.shields.io/badge/License-Apache%202.0-blue.svg',
return badges[license];
I dont know if the issue is the 2 objects are declared as strings, so I’m just confused
2
Based on the information you’ve provided, the code snippet for generating the license badge URL looks correct. The issue you’re experiencing is likely not related to how you’re generating the URL, but rather how you’re using it in your Markdown file.
Let’s consider a few possible reasons why the image isn’t displaying:
- Markdown syntax: Make sure you’re using the correct Markdown syntax for images. In Markdown, an image is inserted using the following format:

So, your badge should be inserted like this:

-
File path: If you’re generating a local Markdown file, ensure that it is saved in the correct location relative to where you’re viewing it.
-
GitHub Markdown: If you’re using this README on GitHub, make sure you’re not accidentally escaping any characters in the URL.
-
Network issues: If you’re viewing the file locally, ensure you have an internet connection, as the badge is loaded from an external URL.
-
Badge service: Verify that the shields.io service is accessible and the specific badge URL is working by trying to open it directly in a browser.