Unable to fetch service from context

Here’s the code while making request to the session. fetch(“http://localhost:8080/openmrs/ws/rest/v1/session”, { headers: { ‘Authorization’: Basic ${btoa('Admin:Admin123')} } }).then(response => { response.json().then(data => { sessionId = data.sessionId }) })

Now in order to use the same token/JSESSIONID return in the above request here’s the code we are using. fetch(“http://localhost:8080/openmrs/ws/rest/v1/user”, { headers: { ‘Cookie’: JSESSIONID=${sessionId} }, }).then(res => { console.log(res.json()); })

But this code won’t work. Because browser doesn’t allow you to set the cookie manually.

NOTE: The openmrs and the client application both are running on different domains.