Simple question: POST or GET, regarding image upload? [closed] - javascript

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 months ago.
Improve this question
In my backend API, I return information based on an image that a user uploads; ie. the user "gets" data depending on the image they inputted. Should this be a GET request or a POST request?
I was thinking it should be a GET request, but my code only seems to work if it's a POST request (specifically, the backend server only seems to get the inputted image if the request is a POST request).
Thanks!

Use POST Method only to upload files.
GET won't work as it doesn't have body to pass on values/files

Related

XMLHttpRequest without server feedback [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 days ago.
This post was edited and submitted for review 3 days ago.
Improve this question
xht = new XMLHttpRequest();
xht.open("POST", "nload");
xht.send(fg);
Shown code send a POST request to server. "nload" flag signals the server to don´t send data back. This is deliberately want! The flag is self programmed and not official. When strstr(str1, "nload") server don´t send data back. My client (Chrome) print a error because server doesn´t send data back shown in picture.
I tried to use "GET" instead of "POST" and navigator.sendBeacon() but booth has same result.
I looking for solutions to solve the error

User credentials seen in header form data even after using https [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Passing user credential from Angular to PHP, they are totally visible in developer tools > Network > Headers > Form data, see below image:
I am using Https everywhere but still my credentials are seen in plain text.
What am I doing wrong?
There are 4 ways to "hide" parameters from appearing in the developers tools:
1st (weakest) encode it
Depending on the algorithm, the data is unreadable afterwards but can easily be decoded to the plaintext
2st Hash the data
The data is unreadable afterwards but you cannot read it yourself too.
3rd Encrypt data
Requires passwords / keys to be sent, leaving you with a dilemma.
4th and probably strongest: Don't send the data at all
Store the secret on the server and link it to the public session id.

Difference between Ajax return Response function and only return [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
What is the difference between having the following in an ajax request / call (is it request or call?)
return $output;
and
return Response($output);
both work, but Response does not give me information about the returned element while return only does give me information.
AJAX is a call actually but as we are requesting to server for send us response against some query that's why we call it AJAX request.
I'm not so sure but Reponse($output) in PHP yields you the modified response from server, by modified response I mean the filtered information to your request and response($output) gives the whole body of response coming from Back end.

How to get and pass the key in another API in Postman [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have an application wanted to implement this scenario in Postman - where i have to create and get the Key and pass the same key to another API to delete
Usually you have an endpoint to generate your key, like a login post request which returns your user information and token.
Do you have something like that? Let me show you how this could be done:
After that you get this key/token and use it in the Header tab to send this value in your next request. Something like this:
When you get the token/key in your response body of the first request, set it into an environment variable in Tests section like this.
var body = JSON.parse(responseBody);
postman.setEnvironmentVariable("AccessKey", body[accessKey]);
After that you can use it in your next request URL as
http://your-api-endpoint/{{AccessKey}}

Get form values (regular post form submit) using jquery [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a form inside a page A, with 2 fields, user and password, the action of my form is a page B.
I would like to get the form values of the request header using javascript when the page B is loaded. Is this possible? Or something similar?
Thanks.
No. Expect for a few exceptions (useragent) the HTTP request headers are not available in client-side Javascript.
The only way to access the values of the POST:ed form would be to place them in the document when processing the request server side.
This however does not apply to Ajax requests, where the entire request and response are exposed to Javascript.
But, if the form uses the GET method the form values are encoded as query parameters and are available by parsing window.location.

Categories