# Unable to fetch service from context

**URL:** <https://talk.openmrs.org/t/unable-to-fetch-service-from-context/32267>\
**Category:** Development\
**Created:** [February 18, 2021, 11:13am UTC](https://talk.openmrs.org/t/unable-to-fetch-service-from-context/32267 "2021-02-18T11:13:19Z")\
**Posts on this page:** 1\
**Showing post:** 23

<div class="post-metadata">

**Author:** ![goylshubham](https://talk.openmrs.org/user_avatar/talk.openmrs.org/goylshubham/32/10878_2.png) [@goylshubham](https://talk.openmrs.org/u/goylshubham)\
**Post date:** [February 27, 2021, 7:13am UTC](https://talk.openmrs.org/t/unable-to-fetch-service-from-context/32267/23 "2021-02-27T07:13:30Z")

</div>

Here’s the code while making request to the session. fetch(“[http://localhost:8080/openmrs/ws/rest/v1/session](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](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.

---

_[View the full topic](https://talk.openmrs.org/t/unable-to-fetch-service-from-context/32267)._
