Giter Site home page Giter Site logo

d2's Introduction

d2

Build Status Test Coverage Code Climate npm version


Documentation

The full api documentation is available at full api documentation

Quickstart guide

Install

Start with adding d2 to your project.

yarn add d2 or npm install d2

After installing you will be able to import the library into your project by using the files in the lib folder.

// Using ES2015 imports
import d2 from 'd2/lib/d2';

// Using CommonJS imports
var d2 = require('d2/lib/d2');

If you want to use d2 as just a global variable on the window object you can include one of the following scripts in your page d2/lib/d2-browser.js or d2/lib/d2-browser.min.js

Initialise the library

To be able to use d2 you will first need to initialise the library. This is required to let the library know where it should load data from (e.g. the schemas, currentUser, authorities). The schemas are the definitions of the data model as it is used in DHIS2.

To do this you have can provide d2 with a baseUrl. (If you don't provide any the default of ../api will be used)

import { init } from 'd2/lib/d2';

init({ baseUrl: 'http://apps.dhis2.org/dev/api' })
  .then(d2 => {
    //Your d2 is initialised and ready to use.
  });

Get first page of users and print their name

d2.models.user.list()
  .then(userCollection => {
    userCollection.forEach(user => console.log(user.name)));
  });

Getting started

To get started we suggest you read the Overview

If you are already fairly familiar what you are probably looking for would be the reference material on what is available on the instance of d2.

For more information on how the Models work the model module documentation and the classes in the module are the current go to reference material.

For other questions see the FAQ or the full api documentation.

d2's People

Contributors

markionium avatar nicolayr avatar birkbjo avatar adhbh avatar jenniferarnesen avatar danse avatar awnage avatar michaelgundlach avatar

Watchers

Renjith P N avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.