# Development Process for Working with Genie and Javascript REST API

**URL:** https://discourse.julialang.org/t/development-process-for-working-with-genie-and-javascript-rest-api/41336
**Category:** General Usage
**Tags:** question
**Created:** [June 13, 2020, 6:20pm UTC](https://discourse.julialang.org/t/development-process-for-working-with-genie-and-javascript-rest-api/41336 "2020-06-13T18:20:21Z")
**Posts on this page:** 1
**Showing post:** 10

<div class="post-metadata">

### Author: ![whenning](https://avatars.discourse-cdn.com/v4/letter/w/9fc348/32.png) [@whenning](https://discourse.julialang.org/u/whenning)
#### Post date: [June 29, 2020, 3:42pm UTC](https://discourse.julialang.org/t/development-process-for-working-with-genie-and-javascript-rest-api/41336/10 "2020-06-29T15:42:03Z")

</div>

@fonsp I am able to successfully communicate between my development front-end and development Julia servers (which is great), but I am getting a CORS error when I try and fetch:

```julia
Access to fetch at 'http://127.0.0.1:8000/random' from origin 
'http://localhost:3000' has been blocked by CORS policy: 
The 'Access-Control-Allow-Origin' header contains the invalid value ''. 
Have the server send the header with a valid value, or, if an opaque 
response serves your needs, set the request's mode to 'no-cors' 
to fetch the resource with CORS disabled.

```

**routes.jl**

```julia
using Genie, Genie.Router, Genie.Renderer.Json, Genie.Requests
using HTTP

Genie.config.run_as_server = true
Genie.config.cors_allowed_origins = ["*"]

route("/random", method="POST") do
  dim = parse(Int, get(@params, :dim, "2"))
  num = parse(Int, get(@params, :num, "3"))
  (:random => rand(dim,num)) |> json
end

Genie.startup()

```

**relevant App.js**

```julia
let params = {
  dim: '1',
  num: '3'
}

const url = 'http://127.0.0.1:8000/random'
fetch(url, {
            method: 'POST',
            mode: "cors", 
            body: params               
          })
.then(response => response.json())
.then(data => console.log(data))
.catch(()=>console.log('Wade- you cant access the url response'));

```

---

_[View the full topic](https://discourse.julialang.org/t/development-process-for-working-with-genie-and-javascript-rest-api/41336)._
