ESP32 C3 DevkitM-1 wifi connection issue

So basically i want to configure my esp32 c3 board to connect to wifi but it doesn’t connect and the board resets after sometime. Although i have enabled USB CDC by giving these statements in the platformio.ini file:

build_flags = 
	-D ARDUINO_USB_MODE=1
	-D ARDUINO_USB_CDC_ON_BOOT=1

I’m still not able to connect to the wifi. This is the code snippet i’ve used to connect to the wifi:

void initWiFi() {
  WiFi.mode(WIFI_STA);
  delay(1000);
  WiFi.begin(ssid, password);
  delay(1000);
  Serial.print("Connecting to WiFi ..");
  if(WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.print("connection failed");
    return;
  }
  Serial.println(WiFi.localIP());
}

Platform.ini file config:

[env:esp32-c3-devkitm-1]
platform = https://github.com/platformio/platform-espressif32.git
board = esp32-c3-devkitm-1
framework = arduino
platform_packages =
    framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#2.0.7
    toolchain-xtensa-esp32@8.4.0+2021r2-patch5
lib_deps = 
	ottowinter/ESPAsyncWebServer-esphome@^3.1.0
	arduino-libraries/Arduino_JSON@^0.2.0
build_flags = 
	-D ARDUINO_USB_MODE=1
	-D ARDUINO_USB_CDC_ON_BOOT=1
monitor_speed = 115200