Currently, I am working with JavaScript and JSON. My goal is to retrieve data from an API where objects contain specific details. Specifically, I need to display the details of an object named "foo.txt" which includes elements such as size, raw_url, content etc. My main focus is on obtaining the raw_url.
How can I achieve this task?
document.getElementById("demo").innerHTML = data.files.foo(?)['raw_url']
JSON sample:
object {url: "https://api.github.com/gists/884c8343dca5b322bf6f", forks_url: "https://api.github.com/gists/884c8343dca5b322bf6f/forks", commits_url: "https://api.github.com/gists/884c8343dca5b322bf6f/commits", id: "884c8343dca5b322bf6f", git_pull_url: "https://gist.github.com/884c8343dca5b322bf6f.git"…}
comments: 0
comments_url: "https://api.github.com/gists/884c8343dca5b322bf6f/comments"
commits_url: "https://api.github.com/gists/884c8343dca5b322bf6f/commits"
created_at: "2015-11-19T09:35:23Z"
description: "test"
files: Object
foo.txt: Object
content: "sdfasfd"
filename: "foo.txt"
language: "Text"
raw_url: "https://gist.githubusercontent.com/anonymous/884c8343dca5b322bf6f/raw/5234994707b7b85bec9c80e50cb0b7dfca050e3b/foo.txt"
size: 7
truncated: false
type: "text/plain"