Skip to content
Advertisement

Tag: xmlhttprequest

How to format a string of html in json

I am working on a tool for generating html files. The code is fairly simple. A user clicks a post button and the content from a textarea is sent to an endpoint. I have tried posting the html as a json string. Expected The saveContent method is called. The value from the textarea element is concatenated into a string. This

How to make AJAX request in Hackerrank using JavaScript?

I open the Hackerrank example test and play around with methods one might use to make an AJAX call. XMLHttpReq, fetch, etc. None of them work; XHR and fetch methods are unavailable. First fetch: Hackerrank throws an error because fetch is not a function. I also tried window.fetch and global.fetch to no avail. I tried XHR: Hackerrank says XMLHttpRequest is

Can’t make new fetch request after aborting previous

I need to change a parameters that defines what data should come from my requests, also this application needs to refresh on a regular time interval. If the user changes the parameter in the middle of an unfinished request things start to behave strange and some unexpected behavior occurs. So my approach was to abort all previous requests before starting

Axios change http to https

I have server that accept only http (no https). And when I call an api, axios automatically change http to https. I create axios instance here: But in browser http changes to https, so it become: https://xxx.xxx.xxx/api/v1/all and I get net::ERR_NAME_NOT_RESOLVED How can I prevent that? UPDATE Request Header: and there is no response header. and now I get net::ERR_SSL_PROTOCOL_ERROR

Where to place async/await in this case?

EDIT: The problem was not the placement of the async/await per se, but the fact that I was trying to make a constructor asynchronous. I have looked through docs, read other questions and answers, but I still can’t get my head wrapped around what function to make async, and where to place the await, to get the behaviour that I

Advertisement