getj(uri: string): Promise<Object>
The getj
function is an asynchronous function that retrieves JSON-LD or JSON data from a given URI.
uri
(string): The URI from which to fetch the JSON-LD or JSON data.import getj from 'getj'
getj('https://example.com')
.then(json => {
console.log(json)
})
.catch(error => {
console.error('Error:', error)
})
The getj
function takes a URI as input and performs the following steps:
<script>
element with a type
attribute of “application/ld+json” or “application/json”.<script>
element into a JSON object.