'export' may only appear at the top level

Hey, I’m getting an error
“Modifiers cannot appear here.
Parsing error: ‘import’ and ‘export’ may only appear at the top level”
Here’s the screenshot of the jsw file


If I try to move export outside, I can’t get the constant ‘tonumber’. What to do? Please help.

Here’s the code in the text format.

import wixData from ‘wix-data’ ;
import twilio from ‘twilio’
wixData . query ( ‘subscribers10’ )
. descending ( “_createdDate” )
. find (). then ( results => {
const tonumber = results . items [ 0 ]. lastName ;
const accountSID = ‘xxxxxxxxxxx’
const authToken = ‘xxxxxxxxxxx’
const twilioNumber = ‘xxxxxxxxxxx’

**export async function**  sendSms () 

{
let client = new twilio ( accountSID , authToken )
let message = await client . messages . create ({
body : ‘Hey! Test Message’ ,
to : ‘whatsapp:+91’ + tonumber ,
from : twilioNumber
})
}
})
Thanks in advance

Try:

import wixData from 'wix-data';
import twilio from 'twilio';
export function sendSms(){
return wixData.query('subscribers10')
 .descending("_createdDate")
 .find()
.then(results => {
    const tonumber = results.items[0].lastName;
    const accountSID = 'xxxxxxxxxxx'
    const authToken = 'xxxxxxxxxxx'
    const twilioNumber = 'xxxxxxxxxxx'
    let client = new twilio(accountSID, authToken)
    return client.messages.create({
        body: 'Hey! Test Message',
        to: 'whatsapp:+91' + tonumber,
        from: twilioNumber
    });
})
    }