You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// GET requestconstaxios=require('axios');axios.get('https://example.com/data').then(response=>console.log(response.data)).catch(error=>console.error(error))
// POST requestconstaxios=require('axios');axios.post('https://example.com/data',{name: 'John Doe',email: '[email protected]'}).then(response=>console.log(response.data)).catch(error=>console.error(error))
# POST request
curl -X POST -H 'Content-Type: application/json' -d '{"name": "John Doe", "email": "[email protected]"}' https://example.com/data
Python
importrequests# GET requestresponse=requests.get('https://example.com/data')
ifresponse.status_code==200:
data=response.json()
print(data)
else:
print(f'Request failed with status code {response.status_code}')
# POST requestresponse=requests.post('https://example.com/data', json={
'name': 'John Doe',
'email': '[email protected]'
})
ifresponse.status_code==200:
data=response.json()
print(data)
else:
print(f'Request failed with status code {response.status_code}')