G
G
gooseNjuice()2022-02-07 18:37:20
AJAX
gooseNjuice(), 2022-02-07 18:37:20

What is the difference between the two requests?

Why does the first request return 200,

fetch("https://api.peopledatalabs.com/v5/autocomplete?api_key=someAPIKey&field=location")

and the second 400/401?
fetch(`https://api.peopledatalabs.com/v5/autocomplete`, {
    "api_key": "someAPIKey",
    "field": "location"
    });

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex, 2022-02-07
@gooseNjuice

Because the second request does not send api_key and field to the server.

What is the difference between the two requests?

Open the debugger and examine what is being sent

I
I Phoenix I, 2022-02-07
@PhoenixX33i

Learn more about the fetch method: learn.javascript | MDN

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question