I am trying to perform an Axios request using the URL type. But I get the error Argument type URL is not assignable to parameter type string
import { Injectable } from '@nestjs/common'
import { NotificationsInterface } from '../interface/notifications.interface'
import { OS, UserType } from '../../global.constants'
const axios = require('axios').default
@Injectable()
export class NotificationsGateway implements NotificationsInterface {
readonly urlDevices = new URL(
'https://blablablabla.amazonaws.com/Prod/devices'
)
async saveDeviceAuthenticationInfos(
userId: number,
userType: UserType,
deviceId: number,
pushToken: string,
operatingSystem: OS
): Promise<void> {
const body = {
userId,
userType,
deviceId,
pushToken,
operatingSystem,
}
await axios.post(this.urlDevices, body)
}
}
How am I suppose to make it work? I am half a mind to put it back into a string, but I feel like it's a regression.
this.urlDevices.toString(), or have a facade for Axios that accepts aURL(which would have other benefits), but what was the objective in making it aURLto start with?.toString()to stringify the url:await axios.post(this.urlDevices.toString(), body)