You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
571 B

4 years ago
  1. function getCookie(name) {
  2. var value = "; " + document.cookie;
  3. var parts = value.split("; " + name + "=");
  4. if (parts.length == 2) return parts.pop().split(";").shift();
  5. }
  6. fetch('http://api.kfcoding.com/api/practice/trains/competition/begin', {
  7. headers: {
  8. 'Content-Type': 'application/json',
  9. Authorization: getCookie('token')
  10. },
  11. method: 'POST',
  12. body: JSON.stringify({repo: 'https://github.com/openx-lab/go-study-guide.git'})
  13. }).then(resp => resp.json())
  14. .then(data => {
  15. if (data.data)
  16. localStorage.setItem('comp_id', data.data.id)
  17. });