# Citestore Plugin

**URL:** https://meta.discourse.org/t/citestore-plugin/51620
**Category:** Development
**Created:** [October 16, 2016, 11:56pm UTC](https://meta.discourse.org/t/citestore-plugin/51620 "2016-10-16T23:56:42Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![gdpelican](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gdpelican/32/81308_2.png) [@gdpelican](https://meta.discourse.org/u/gdpelican)
#### Post date: [October 17, 2016, 12:26am UTC](https://meta.discourse.org/t/citestore-plugin/51620/2 "2016-10-17T00:26:13Z")

</div>

Hi, apologies in advance if I’m dev-splaining anything.

The `citestore.js.es6` file is included in the javascript application is sent to your users’ computers when they load up Discourse.

The `plugin.rb` code lives on the server which is running Discourse.

The way those two things communicate is through API requests. So, for instance, if I load this topic in meta, there’s a request from my computer to the server, requesting information about the topic. You can see what network requests are being made by visiting the ‘Network’ tab in chrome:

 ![](https://global.discourse-cdn.com/meta/original/3X/e/d/ed89d4ed7e88eecfe54d56004085feb1424f1895.png)  
(that’s a picture of me requesting the first post in topic 51620. There are many like it, but this one is yours. Note that I’ve filtered out most of the other requests by typing ‘/t/’ into the filter box up top.)

On the client side, you can initiate a request using the `ajax` library:

```plaintext
import { ajax } from 'discourse/lib/ajax'
getThing() {
  ajax('/citestores/us-constitution-1', function(data) {
    // in here, you can use the data you've fetched!
  })
}

```

On the server side, you’ll need to set up a route and a controller to respond with some data when that request is initiated

```plaintext
  Discourse::Application.routes.append do
    get '/citestores/:key', to: 'citesstores#show'
  end

```

```plaintext
CitestoresController < ApplicationController
  def show
    @citestore = Citestore::Storage.get(params[:key])
    respond_with json: { handle: @citestore.handle, locus: @citestore.locus } 
  end
end

```

NB: this code is an untested approximation, but should at least get you towards communicating between client and server. 😃

---

_[View the full topic](https://meta.discourse.org/t/citestore-plugin/51620)._
