I have an API that responds to an API call like below in Postman:
The body is just
"username": "bobmarley"
How can I replicate this in my React/Next project. Here is what I currently have:
export async function getUser(data) {
const response = await fetch(http://localhost:4000/users/:username
, { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(data) }) var response_data = await response.json();
return(response_data); }
How can I pass these path variables like in Postman too?
https://stackoverflow.com/questions/66947501/path-variables-in-react-api-call April 05, 2021 at 10:06AM
没有评论:
发表评论