.fetch()

Returns the value of the provided key directly from the JSON file.

fetch(key)

Parameter

Description

key

String

The key to get the value from

Returns

Description

The value of the provided key

db.set('Greeting', 'Hello World'); // 'Hello World'

db.fetch('Greeting'); // 'Hello World'

Also allows the use of dot notation:

db.set('user', { name: 'Peter', age: 19 }); // { name: 'Peter', age: 19 }

db.fetch('user.name'); // 'Peter'
db.fetch('user.age'); // 19
db.fetch('user.hobbies'); // undefined

Last updated