Fetch not returning results

Anyone can tell me what I am doing wrong here. The website is a single line string. But I keep getting undefined as result.

Thanks.

import {fetch} from ‘wix-fetch’ ;

export async function getVATSIMMetar(){
let url = ‘http://metar.vatsim.net/KCLT’ ;

await fetch (url, { “method” : ‘get’ })
.then( async (httpResponse) => {
let result = await httpResponse.text();
return result
})
}

You are returning a value from within a .then function. You might also want to avoid using ‘await’ on every line.

Looking here might help.

Depending on when/how you need the http response, you could use something like this.

import {fetch} from ‘wix-fetch’ ;

export async function getVATSIMMetar( )
{
let url = ‘http://metar.vatsim.net/KCLT’ ;

var result;

await fetch (url, { ‘method’ : ‘get’ })
.then( httpResponse => httpResponse.text() )
.then( text => {
result = text;
})

return result;
}

export async function MainFunction( )
{
console.log( await getVATSIMMetar() );
return 0 ;
}

Thanks that worked.