Skip to content

Latest commit

 

History

History
368 lines (317 loc) · 6.39 KB

axios.md

File metadata and controls

368 lines (317 loc) · 6.39 KB

Examples using Axios

1. Get all saved users

HTTP Method

GET

Endpoint /reddit_users/
Example
const axios = require('axios');

axios.get('http://127.0.0.1:8080/reddit_users/', {
  headers: {
    Authorization: 'Basic cAebyYIUtX-3urYrp05_GlxtrVgLUKX7rQxDBdG5mGA',
  },
})
  .then(response => console.log(response.data))
  .catch(error => console.error(error));

2. Get specific user

HTTP Method

GET

Endpoint /reddit_users/{USER}/
Example
const axios = require('axios');

axios.get('http://127.0.0.1:8080/reddit_users/spez/', {
  headers: {
    Authorization: 'Basic cAebyYIUtX-3urYrp05_GlxtrVgLUKX7rQxDBdG5mGA',
  },
})
  .then(response => console.log(response.data))
  .catch(error => console.error(error));

3. Create a new user

HTTP Method

POST

Endpoint /reddit_users/
Example
const axios = require('axios');

axios.post('http://127.0.0.1:8080/reddit_users/', {
  username: 'new_user',
  password: 'new_password',
  client_id: 'new_client_id',
  client_secret: 'new_client_secret',
}, {
  headers: {
    Authorization: 'Basic cAebyYIUtX-3urYrp05_GlxtrVgLUKX7rQxDBdG5mGA',
    'Content-Type': 'application/json',
  },
})
  .then(response => console.log(response.data))
  .catch(error => console.error(error));

4. Update user information

HTTP Method

PUT

Endpoint /reddit_users/{USER}/
Example
const axios = require('axios');

axios.put('http://127.0.0.1:8080/reddit_users/spez/', {
  username: 'spez',
  password: 'new_password',
  client_id: 'new_client_id',
  client_secret: 'new_client_secret',
}, {
  headers: {
    Authorization: 'Basic cAebyYIUtX-3urYrp05_GlxtrVgLUKX7rQxDBdG5mGA',
    'Content-Type': 'application/json',
  },
})
  .then(response => console.log(response.data))
  .catch(error => console.error(error));

5. Delete a user

HTTP Method

DELETE

Endpoint /reddit_users/{USER}/
Example
const axios = require('axios');

axios.delete('http://127.0.0.1:8080/reddit_users/spez/', {
  headers: {
    Authorization: 'Basic cAebyYIUtX-3urYrp05_GlxtrVgLUKX7rQxDBdG5mGA',
  },
})
  .then(response => console.log(response.data))
  .catch(error => console.error(error));

6. Get all scheduled submissions

HTTP Method

GET

Endpoint /scheduled_submissions/
Example
const axios = require('axios');

axios.get('http://127.0.0.1:8080/scheduled_submissions/', {
  headers: {
    Authorization: 'Basic cAebyYIUtX-3urYrp05_GlxtrVgLUKX7rQxDBdG5mGA',
  },
})
  .then(response => console.log(response.data))
  .catch(error => console.error(error));

7. Schedule a new submission

HTTP Method

POST

Endpoint /scheduled_submissions/
Example
const axios = require('axios');

axios.post('http://127.0.0.1:8080/scheduled_submissions/', {
  username: 'spez',
  planned_unix_datetime: 1753876468,
  sub: 'ProgrammerHumor',
  title: 'New submission',
  text: 'Lorem ipsum dolor sit down',
  flairid: null,
  nsfw: false,
  crosspost_requests: [{
    sub: 'EtsyMemes',
    planned_unix_datetime: 1753877470,
  }],
}, {
  headers: {
    Authorization: 'Basic cAebyYIUtX-3urYrp05_GlxtrVgLUKX7rQxDBdG5mGA',
    'Content-Type': 'application/json',
  },
})
  .then(response => console.log(response.data))
  .catch(error => console.error(error));

8. Get details of a specific submission

HTTP Method

GET

Endpoint /scheduled_submissions/{SUBMISSION_ROWID}/
Example
const axios = require('axios');

axios.get('http://127.0.0.1:8080/scheduled_submissions/1/', {
  headers: {
    Authorization: 'Basic cAebyYIUtX-3urYrp05_GlxtrVgLUKX7rQxDBdG5mGA',
  },
})
  .then(response => console.log(response.data))
  .catch(error => console.error(error));

9. Update a scheduled submission

HTTP Method

PUT

Endpoint /scheduled_submissions/{SUBMISSION_ROWID}/
Example
const axios = require('axios');

axios.put('http://127.0.0.1:8080/scheduled_submissions/1/', {
  username: 'spez',
  planned_unix_datetime: 1753876468,
  sub: 'ProgrammerHumor',
  title: 'Updated submission',
  text: 'Lorem ipsum dolor sit down',
  flairid: null,
  nsfw: false,
}, {
  headers: {
    Authorization: 'Basic cAebyYIUtX-3urYrp05_GlxtrVgLUKX7rQxDBdG5mGA',
    'Content-Type': 'application/json',
  },
})
  .then(response => console.log(response.data))
  .catch(error => console.error(error));

10. Delete a scheduled submission

HTTP Method

DELETE

Endpoint /scheduled_submissions/{SUBMISSION_ROWID}/
Example
const axios = require('axios');

axios.delete('http://127.0.0.1:8080/scheduled_submissions/1/', {
  headers: {
    Authorization: 'Basic cAebyYIUtX-3urYrp05_GlxtrVgLUKX7rQxDBdG5mGA',
  },
})
  .then(response => console.log(response.data))
  .catch(error => console.error(error));
```

Make sure to replace the placeholders such as {USER} and {SUBMISSION_ROWID} with the actual values in your requests.