Skip to content

Latest commit

 

History

History
40 lines (39 loc) · 1.91 KB

README_old.md

File metadata and controls

40 lines (39 loc) · 1.91 KB

Old Method

This method directly sends the network request.

  1. Install Postman and Postman Interceptor
  2. Set up Capture requests and cookeis on Postman. Make sure to: sync and capture cookeis on icbc.com
  3. Now search the available test on ICBC Website. If you do it correctly, you should be able to see the getAvailableAppointments on Network requests.
  4. Copy the getAvailableAppointments request as cURL (bash)
  5. Import it to Postman as Raw text. Send it and you will get a HTTP 200 response.
  6. Copy the code snippet as JavaScript - Fetch
  7. Paste it on the Console tab. You will see it returns a list of schedules
  8. Now run my script
    // get an alert when found an appointment before the date below
    let preferToBeBefore = new Date("2022-06-01");
    let checkDate = () => fetch("https://onlinebusiness.icbc.com/deas-api/v1/web/getAvailableAppointments", requestOptions)
    .then(response => response.text())
    .then(result => JSON.parse(result))
    .then(oResult => {
        const foundDate = new Date(oResult[0]?.appointmentDt.date);
        const result = foundDate < preferToBeBefore
        console.log(`Earliest date: ${foundDate}; Less than ${preferToBeBefore}: ${result}`)
        if (result) {
            alert(`BOOK NOW: ${foundDate}`)
        } else {
            setTimeout(() => {
                checkDate();
            }, 0)
        }
    })
    .catch(error => console.log('error', error));
    
    checkDate();
  9. Once alert is triggered, go reschedule the appointment ASAP!
  10. Good luck on your road test! And fuck ICBC examiners!