Today, when learning fetch, to learn get and post, in the course of the experiment, it was found that get could successfully obtain the data in api, but post did not know where it went wrong. There is no problem with the get method as follows
fetch("https://search.heweather.com/find?location=&key=bc08513d63c749aab3761f77d74fe820",{
method:"GET"
}) // Promise
.then((res)=>{
return res.json();
})
.then((res)=>{
console.log(res) // res
})
but the post method does not know what is wrong. Please point out
const content = {location:"",key:"bc08513d63c749aab3761f77d74fe820"}
fetch("https://search.heweather.com/find",{
method:"POST",
body:JSON.stringify(content)
}) // Promise
.then((res)=>{
return res.json();
})
.then((res)=>{
console.log(res) // res
})
// invalid key
or can this API be called only in GET mode? For beginners to learn the knowledge of API, please give us a detailed explanation. Thank you