Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const getData = async () => {
- try{
- const response = await fetch('https://api-to-call.com/endpoint', {
- method: 'POST',
- body: JSON.stringify({id: 200})
- })
- if (response.ok){
- const jsonResponse = await response.json();
- return jsonResponse;
- }
- throw new Error('Request failed!');
- } catch(error){
- console.log(error);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement