Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting "ERPROTO" when trying to make an Axios call from my REST API

My API is located at "localhost:3000/api/shopitems" and returns the following JSON data successfully when requested via a browser:

[
    {
        "item_available_sizes": {
            "s": 1
        },
        "imgs": {
            "album": [],
            "thumbnail": "assets/imgs/square_sample1-1.jpg",
            "main": "assets/imgs/sqare-sample1.jpeg"
        },
        "item_categories": [
            "dresses"
        ],
        "_id": "5e6c73b3daafdd9f1890d691",
        "item_name": "Low Back Strappy Maxi Dress",
        "item_price": 84.99,
        "item_description": "Long dress",
        "__v": 0
    }
]

However, when I make the request with the following code:

axios.get('https://localhost:3000/api/shopitems')
    .then(data => console.log(data))
    .catch(err => console.log(err))

I get the following error:

   Error: write EPROTO 15224:error:1408F10B:SSL 
    routines:ssl3_get_record:wrong version 
    number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:

    at WriteWrap.afterWrite [as oncomplete] (net.js:788:14)
    errno: 'EPROTO'

What am I doing wrong that this is happening? I am using mongodb/mongoose, Express, NodeJS.

like image 956
Quan Cao Avatar asked Oct 29 '25 03:10

Quan Cao


1 Answers

It seems the problem is that you are using https. Change it to this and tell us if it works for you

axios.get('http://localhost:3000/api/shopitems')
.then(data => console.log(data))
.catch(err => console.log(err))
like image 152
ousecTic Avatar answered Oct 30 '25 16:10

ousecTic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!