P
P
prolina2020-07-17 00:00:17
AJAX
prolina, 2020-07-17 00:00:17

How to make a GET request until the response from the POST request is returned?

I need to upload a file. As soon as I have selected the file, there is a POST request to the api and until the response is returned, I need to make a GET request to the api in order to get the progress of the uploaded file and display it. How can this be implemented? I tried using axios onUploadProgress, but then there are too many GET requests and the last one returns the wrong value.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Somewhere Intech, 2020-07-17
@john36allTa

How not to do it - but how to do it
1. You need to understand that the browser subsystem checks the status of the file delivery to the server and can tell you how much is left. Just take my word for it :) A get request can come in handy when you received a response from axios about a successful upload and make a get request to the server, saying "Is everything okay, is the file saved (maybe the place ran out at the time of copying - who knows who is there and where the spit ". And your scheme smacks of a ddos ​​attack, if you look at the scale of a huge project%)

I tried using axios onUploadProgress, but then there are too many GET requests and the last one returns the wrong value.

Are you sending get requests from this callback?

P
Pavel K, 2014-12-22
@PavelK

Can you see the processing script itself from the server side?
And in my opinion UploadFile has two parameters.
And what does "nothing happened" mean? What is given in response?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question