SHOW:
|
|
- or go back to the newest paste.
1 | - | fetch('https://api-to-call.com/endpoint', { |
1 | + | fetch('https://crackitindonesia.net/members/api/auth/ver2/login/', { |
2 | ////this second argument containing method and body determines that this request is a POST request and what information will be sent to the API. | |
3 | method: 'POST', | |
4 | body: JSON.stringify({id: '200'}) | |
5 | }).then(response => { | |
6 | if (response.ok){ | |
7 | return response.json(); | |
8 | } | |
9 | throw new Error('Request failed!'); | |
10 | }, networkError => { | |
11 | console.log(networkError.message); | |
12 | }).then(jsonResponse => { | |
13 | return jsonResponse | |
14 | }); |