import { InboundResponseHeadersT } from './types'
export const handler = async () => {
let status = true
let lastId: string | null = null
while (status) {
try {
//. ERROR IS HERE
let { data, messageData } = await axios
.get('https://xxxxxxxx/httpadapter/inbound', {
httpsAgent: new https.Agent({ rejectUnauthorized: false }),
headers: {
'X-DeleteAfterConfirmation': true,
'X-LastId': lastId,
},
auth: {
username: 'xxx',
password: 'xxxx',
},
})
.then((res) => ({
data: res.data as string,
messageData: res.headers as InboundResponseHeadersT,
}))
const parser = new XMLParser({ ignoreAttributes: false })
let obj = parser.parse(data)
await watchEvent(obj, messageData['x-conversationid'])
lastId = messageData['x-id']
} catch (err) {
status = false
break
}
}
}
The exporting type
export type InboundResponseHeadersT = {
'x-messageversion': string
'x-backendreceiverid': string
'x-schemaset': string
'x-conversationid': string
'x-id': string
'x-filename': string
'x-messageid': string
'content-type': 'text/xml'
'x-backendsenderid': string
'x-messagetype': string
'x-content-type-options': string
'x-xss-protection': string
'strict-transport-security': string
'x-frame-options': string
'content-length': string
}
I have the following problem that my TS says that messageData
has type any
even if i set the type in the return statement. What am i doing wrong here?
EDIT:
After removing the while()
loop the error dissapear. But i need the loop