This is a very simple example of how to use the Retsly JS SDKs to easily make calls to Retsly from the back- or front-end.
This example assumes that you have a Retsly account and have already registered an application as you will need that application's assets to access the Retsly API. Also, please ensure that you've registered localhost
as a domain in your application setup.
We use an Express server build on Node.js in this example. Consequently, you will also need to have Node/NPM setup on your computer prior to following the instructions below.
This example app includes examples of:
- Retsly/retsly-js-sdk (v1) for frontend requests.
- Retsly/js-sdk (v2) for front- and back-end requests.
- Node/NPM
- Retsly Account
- Registered Retsly Application -- registered domains must include
localhost
for frontend requests
- Clone this repo.
npm install
- Go into the
frontend
folder and replace the<<<client_id>>>
and/or<<<browser_token>>>
with your application's client_id and/or browser token respectively in the files found there. - Go into
server.js
at the root of this repo and replace<<<server_token>>>
on line 34 with your application's server token. - run
npm build
ormake build
in your terminal. These commands will bundle the two existing modules in thefrontend
folder and add them to thepublic
folder. - Run
npm server.js
in your terminal -- the listening port is currently hardcoded to3000
. Feel free to alter this in theserver.js
file found at the root of this repo. - Direct your browser to
localhost:3000
orlocalhost:WHATEVER_PORT_YOU_CHOSE
. The links on the homepage will direct you to the responses received by the request selected. - Modify the code, have fun, and/or profit! If you add files to the frontend folder, make sure to add a line to the
Makefile
at the root of this repo to have browserify compile your added code.
Additional information related to making requests to the Retsly API can be found here.