You must use the fetch method by entering the API address, identify the method (POST
, PUT
,GET
, DELETE
), insert the required header and send the data in the body of the request.
Register
fetch('https://dev.people.com.ai/mobile/api/v2/register/', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
email: '[email protected]',
name: 'Lennon Coelho',
password: 'Senha@12346',
})
}).then((response) => {
return response;
});
Login
fetch('https://dev.people.com.ai/mobile/api/v2/login/', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
email: '[email protected]',
password: 'Senha@12346',
})
}).then((response) => {
return response;
});
If this is your first time using fetch, in some cases you will need to install it and import it, follow the link.
Also you can install some extension like Axios or jQuery AJAX facilitating the call for REST methods.
More guy let me ask you if you can help me could give me an example by passing the name of the API to a components just how to pass
– Filipe Nickel Sala
just insert the name into a variable and put this.variable instead of the API link
– Paz