# Does \`fetch\` method support HTTPS?

**URL:** <https://forums.fusetools.com/t/does-fetch-method-support-https/5457>\
**Category:** General\
**Created:** [December 18, 2015, 12:21pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457 "2015-12-18T12:21:00Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![klayer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/klayer/32/505_2.png) [@klayer](https://forums.fusetools.com/u/klayer)\
**Post date:** [December 18, 2015, 12:21pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/1 "2015-12-18T12:21:00Z")

</div>

Hi,

I’m trying to write a login method but it seems that the `fetch` method don’t support HTTPS protocol. I print the server logs but found no login request.

---

<div class="post-metadata">

**Author:** ![Anders\_Bondehagen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_bondehagen/32/98_2.png) [@Anders\_Bondehagen](https://forums.fusetools.com/u/Anders_Bondehagen)\
**Post date:** [December 18, 2015, 12:25pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/2 "2015-12-18T12:25:40Z")

</div>

Yes, what platform are you running on? Do you have a error handler to catch exceptions?

---

<div class="post-metadata">

**Author:** ![klayer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/klayer/32/505_2.png) [@klayer](https://forums.fusetools.com/u/klayer)\
**Post date:** [December 18, 2015, 12:30pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/3 "2015-12-18T12:30:48Z")

</div>

Running on the local preview, added the error handler but also get nothing. When I change the protocol to HTTP and get normal response.

---

<div class="post-metadata">

**Author:** ![Anders\_Bondehagen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_bondehagen/32/98_2.png) [@Anders\_Bondehagen](https://forums.fusetools.com/u/Anders_Bondehagen)\
**Post date:** [December 18, 2015, 12:34pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/4 "2015-12-18T12:34:12Z")

</div>

Are you on the slack community? Maybe easier to help you there [http://slackcommunity.fusetools.com](http://slackcommunity.fusetools.com)

---

<div class="post-metadata">

**Author:** ![Bjorn-Olav\_Strand](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/bjorn-olav_strand/32/583_2.png) [@Bjorn-Olav\_Strand](https://forums.fusetools.com/u/Bjorn-Olav_Strand)\
**Post date:** [December 18, 2015, 12:45pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/5 "2015-12-18T12:45:37Z")

</div>

@klayer: Is this a public server you can share? Does other HTTPS hosts work?

---

<div class="post-metadata">

**Author:** ![klayer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/klayer/32/505_2.png) [@klayer](https://forums.fusetools.com/u/klayer)\
**Post date:** [December 18, 2015, 12:54pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/6 "2015-12-18T12:54:58Z")

</div>

Sorry, my email can not receive the invite mail…

```auto
    console.log('Begin');
    fetch('https://example.com/api/user/login&#39;, {
        method: 'POST',
        headers: {
            'Content-type': 'application/json'
        },
        body: JSON.stringify({
            'login_name': userName.value,
            'password': hashedPassword
        })
    })
    .then(function(resp) {
        if (resp.status == 200) {
            console.log('OK');
            return resp.json();
        } else {
            console.log('Network failure: ' + resp.status);
        }
    })
    .then(function(json) {
        console.log('JSON:');
        console.log(JSON.stringify(json));
    })
    .catch(function(err) {
        console.log('Error');
        console.log(JSON.stringify(err));
    });

```

In the monitor, I got the following messages:

```auto
LOG: Begin
LOG: Error
LOG: {"message":"Network request failed"}

```

And the Nginx server doesn’t receive any request ;(

---

<div class="post-metadata">

**Author:** ![Bjorn-Olav\_Strand](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/bjorn-olav_strand/32/583_2.png) [@Bjorn-Olav\_Strand](https://forums.fusetools.com/u/Bjorn-Olav_Strand)\
**Post date:** [December 18, 2015, 12:57pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/7 "2015-12-18T12:57:48Z")

</div>

Can you load other `https` resources? Can you share the actual URL?

---

<div class="post-metadata">

**Author:** ![klayer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/klayer/32/505_2.png) [@klayer](https://forums.fusetools.com/u/klayer)\
**Post date:** [December 18, 2015, 1:07pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/8 "2015-12-18T13:07:44Z")

</div>

The URL is `[https://dp.yiducloud.com.cn/api/user/login](https://dp.yiducloud.com.cn/api/user/login)`. I haven’t try other https resource.

---

<div class="post-metadata">

**Author:** ![Bjorn-Olav\_Strand](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/bjorn-olav_strand/32/583_2.png) [@Bjorn-Olav\_Strand](https://forums.fusetools.com/u/Bjorn-Olav_Strand)\
**Post date:** [December 18, 2015, 1:14pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/9 "2015-12-18T13:14:00Z")

</div>

For me on that url the error handler is thrown:

`ERROR: TypeError: Network request failed`

```auto
    fetch('https://dp.yiducloud.com.cn/api/user/login').then(function (resp) {
        debug_log ("fetch: " + JSON.stringify(resp));
    }).catch(function error (error, e2) {
        debug_log ("ERROR: " + error);
    } );

```

---

<div class="post-metadata">

**Author:** ![Anders\_Bondehagen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_bondehagen/32/98_2.png) [@Anders\_Bondehagen](https://forums.fusetools.com/u/Anders_Bondehagen)\
**Post date:** [December 18, 2015, 1:17pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/10 "2015-12-18T13:17:28Z")

</div>

Strange, I got the following:

```auto
LOG: Begin
LOG: OK
LOG: JSON:
LOG: {"message":"登录失败，用户名或者密码错误。","error":true}

```

Which version of Fuse do you have?

---

<div class="post-metadata">

**Author:** ![klayer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/klayer/32/505_2.png) [@klayer](https://forums.fusetools.com/u/klayer)\
**Post date:** [December 18, 2015, 1:20pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/11 "2015-12-18T13:20:10Z")

</div>

@Anders

it is 0.9.3 （build 5207）

---

<div class="post-metadata">

**Author:** ![Bjorn-Olav\_Strand](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/bjorn-olav_strand/32/583_2.png) [@Bjorn-Olav\_Strand](https://forums.fusetools.com/u/Bjorn-Olav_Strand)\
**Post date:** [December 18, 2015, 1:20pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/12 "2015-12-18T13:20:38Z")

</div>

```
$ fuse --version
Fuse version 0.9.4 (build 5386)
Copyright (C) 2015 Fusetools

```

```
$ curl https://dp.yiducloud.com.cn/api/user/login
<html><title>405: Method Not Allowed</title><body>405: Method Not Allowed</body></html>

```

---

<div class="post-metadata">

**Author:** ![Anders\_Bondehagen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_bondehagen/32/98_2.png) [@Anders\_Bondehagen](https://forums.fusetools.com/u/Anders_Bondehagen)\
**Post date:** [December 18, 2015, 1:25pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/13 "2015-12-18T13:25:30Z")

</div>

Oh wait, you both are on OSX right? Then it might be we found an issue with mono 😛 I will switch to Mac and debug.

---

<div class="post-metadata">

**Author:** ![klayer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/klayer/32/505_2.png) [@klayer](https://forums.fusetools.com/u/klayer)\
**Post date:** [December 18, 2015, 1:26pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/14 "2015-12-18T13:26:26Z")

</div>

OK, I’ll update the latest version and have a try. Thanks guys for helping!

---

<div class="post-metadata">

**Author:** ![klayer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/klayer/32/505_2.png) [@klayer](https://forums.fusetools.com/u/klayer)\
**Post date:** [December 18, 2015, 1:28pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/15 "2015-12-18T13:28:35Z")

</div>

@Anders Yes, I use OSX.

---

<div class="post-metadata">

**Author:** ![admin1](https://avatars.discourse-cdn.com/v4/letter/a/bbce88/32.png) [@admin1](https://forums.fusetools.com/u/admin1)\
**Post date:** [December 27, 2015, 8:54am UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/16 "2015-12-27T08:54:19Z")

</div>

2333333333

---

<div class="post-metadata">

**Author:** ![Anders\_Bondehagen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_bondehagen/32/98_2.png) [@Anders\_Bondehagen](https://forums.fusetools.com/u/Anders_Bondehagen)\
**Post date:** [January 4, 2016, 1:35pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/17 "2016-01-04T13:35:59Z")

</div>

Just a quick update. This is a bug that is happening using some certificates. We are still working on the fix for this.

---

<div class="post-metadata">

**Author:** ![markusdrake](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/markusdrake/32/81_2.png) [@markusdrake](https://forums.fusetools.com/u/markusdrake)\
**Post date:** [April 9, 2016, 5:10am UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/18 "2016-04-09T05:10:54Z")

</div>

Was the exact cause of this ever identified? I’m on OSX and running into an issue where Fetch doesn’t print anything to the log - not for then() nor for catch(). I’m going to test it on the physical device tomorrow night. My server is using HTTPs. You can check out the certificate [https://www.nextplayerup.com](https://www.nextplayerup.com)

---

<div class="post-metadata">

**Author:** ![Anders\_Bondehagen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_bondehagen/32/98_2.png) [@Anders\_Bondehagen](https://forums.fusetools.com/u/Anders_Bondehagen)\
**Post date:** [April 12, 2016, 1:20pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/19 "2016-04-12T13:20:07Z")

</div>

We actually never got to the bottom of it. And other tickets piled up. Tell me how it went on your physical device. If it’s not working I can start digging into it again.

---

<div class="post-metadata">

**Author:** ![Andreas1](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@Andreas1](https://forums.fusetools.com/u/Andreas1)\
**Post date:** [April 25, 2016, 8:53pm UTC](https://forums.fusetools.com/t/does-fetch-method-support-https/5457/20 "2016-04-25T20:53:42Z")

</div>

Hi,

there are still some issues with ‘fetch’ using https with username and password. It works for me with iOS, but the same code does not work with neither Android nor Local.

The code:

```auto
<App Theme="Basic">
  <JavaScript>
    function test() {
      var username = 'user';
      var password = 'passwd';
      var url = 'https://&#39; + username + ':' + password + '@httpbin.org/basic-auth/user/passwd';
      console.log( "requesting " + url );
      fetch( url ).then( function( response ) {
        console.log( 'status: ' + response.status );
        return response.json();
      } ).then( function( responseObject ) {
        console.log( 'response: ' + JSON.stringify( responseObject ) );
      } ).catch( function( err ) {
          console.log( 'Error: ' + err.message );
      } );
    }
    module.exports = {
      test: test
    }
  </JavaScript>
  <Button Text="Test" Clicked="{test}" />
</App>

```

Monitor for iOS:

```auto
LOG: requesting https://user:passwd@httpbin.org/basic-auth/user/passwd
LOG: status: 200
LOG: response: {"authenticated":true,"user":"user"}

```

Monitor for Android:

```auto
LOG: requesting https://user:passwd@httpbin.org/basic-auth/user/passwd
LOG: status: 401
LOG: Error: Unexpected end of input

```

Monitor for Local:

```auto
LOG: requesting https://user:passwd@httpbin.org/basic-auth/user/passwd
LOG: Error: Network request failed

```

In a different project with my Apache-Server, I recognized in the access log that Android and Local do not send username and password (as opposed to iOS).

Thanks,

Andreas

[Next page](https://forums.fusetools.com/t/does-fetch-method-support-https/5457.md?page=2)
