https://github.com/elabftw/elabapi-javascript-example
Example code for doing CORS requests to eLabFTW API
https://github.com/elabftw/elabapi-javascript-example
Last synced: about 2 months ago
JSON representation
Example code for doing CORS requests to eLabFTW API
- Host: GitHub
- URL: https://github.com/elabftw/elabapi-javascript-example
- Owner: elabftw
- License: mit
- Created: 2022-12-05T15:11:52.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-12-09T09:24:54.000Z (5 months ago)
- Last Synced: 2025-01-13T15:49:30.016Z (4 months ago)
- Language: HTML
- Size: 2.93 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eLabFTW Javascript demo
## Description
This example web page shows how to interact with an eLabFTW server through javascript. It requires configuring correctly the eLabFTW service to allow CORS requests.
## Configuration
In the docker-compose file (`/etc/elabftw.yml` by default), add this:~~~yaml
# here the value must the of the service doing the request
- ALLOW_ORIGIN=http://localhost:8087
# comma separated list of methods (use GET, POST, PATCH, DELETE for full api access)
- ALLOW_METHODS=GET
- ALLOW_HEADERS=Content-Type, Authorization
~~~Restart the service (`elabctl restart`).
## Usage
Run a local server with:
~~~bash
git clone https://github.com/elabftw/elabapi-javascript-example
cd elabapi-javascript-example
docker run --rm -v ${PWD}:/usr/share/nginx/html -p 8087:80 -d nginx
~~~Modify the javascript code to point to your server with a valid API Key.
Go to http://localhost:8087 to try it out!