Gilbert Nwaiwu
Gilbert Nwaiwu

Reputation: 728

Aurelia: sending fetch request to different port

I have a PHP backend at port 7000. I use the webpack skeleton. How can I configure my fetch client to send requests to a different port number.

Upvotes: 0

Views: 2108

Answers (1)

qwerty2k
qwerty2k

Reputation: 161

When setting .withBaseUrl('api/') you can just specify a port like url:8000/api and that should work from my experience, there may be a better way but that has worked for me in the past.

Or if you aren't specifying a base url the following should also work:

httpClient.fetch('http://localhost:7000/api/getsomedata')
    .then(response => return response.json())
    .then(data => {
        console.log(data);
    });

Upvotes: 3

Related Questions