WebStorm fetch/put to localhost instead of external api (swagger)

Answered

I'm trying to use fetch / post, to send form data to a swagger api hosted by my university. Unfortunately, when I click send the data is sent to localhost instead of the provided https path.

I have changed the port to 8080, allowed unsigned requests and the accepting of external connections.

The code is still being sent to http://localhost:8080/ which produces a 404 error.

What do I need to do to send the data to the correct destination?

Below you can see my code used to try to send the data.

 

  fetch('https://correct-path.com/api/v1/data', {
        method: 'POST',
        headers: {
            Authorization: 'TOKEN',
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(data)
    });

0
2 comments

Hello, Andereanewsletters. Could you please describe in more detail how exactly I can reproduce the issue on my side? Is it possible to share a sample project?

0

@Andereanewsletters Please could you elaborate on your steps? How are you sending the requests? A video recording that shows what it looks like on your end would be helpful.

0

Please sign in to leave a comment.