I am following this tutorial [https://www.youtube.com/watch?v=mrHNSanmqQ4]
I get 204 errors for all my requests when I test them in my react web app or from Insomnia. The functions produce the correct results in the Realms editor.
The endpoints are set to use System Authentication and I am allowing access from all IP addresses.
The result is the same regardless of the body of the function. For example:
exports = async function({ query, headers, body}, response) {
const collection = context.services.get(âmongodb-atlasâ).db(âsample_restaurantsâ).collection(ârestaurantsâ);
const cuisines = await collection.distinct(âcuisineâ);
return cuisines
};
produces the same result as
exports = async function({ query, headers, body}, response) {
return âHello worldâ;
};
The call from the realm console is just
exports({})
Result from the realm console is
ran at 1658043458424
took 402.199783ms
result:
[
âAfghanâ,
âAfricanâ,
âAmericanâ,
âArmenianâ,
âAsianâ,
âAustralianâ,
âBagels/Pretzelsâ,
âBakeryâ,
âBangladeshiâ,
âBarbecueâ,
âBottled beverages, including water, sodas, juices, etc.â,
âBrazilianâ,
âCafĂ©/Coffee/Teaâ,
âCafĂ©/Coffee/Teaâ,
âCajunâ,
âCalifornianâ,
âCaribbeanâ,
âChickenâ,
âChileanâ,
âChineseâ,
âChinese/Cubanâ,
âChinese/Japaneseâ,
âContinentalâ,
âCreoleâ,
âCreole/Cajunâ,
âCzechâ,
âDelicatessenâ,
âDonutsâ,
âEastern Europeanâ,
âEgyptianâ,
âEnglishâ,
âEthiopianâ,
âFilipinoâ,
âFrenchâ,
âFruits/Vegetablesâ,
âGermanâ,
âGreekâ,
âHamburgersâ,
âHawaiianâ,
âHotdogsâ,
âHotdogs/Pretzelsâ,
âIce Cream, Gelato, Yogurt, Icesâ,
âIndianâ,
âIndonesianâ,
âIranianâ,
âIrishâ,
âItalianâ,
âJapaneseâ,
âJewish/Kosherâ,
âJuice, Smoothies, Fruit Saladsâ,
âKoreanâ,
âLatin (Cuban, Dominican, Puerto Rican, South & Central American)â,
âMediterraneanâ,
âMexicanâ,
âMiddle Easternâ,
âMoroccanâ,
âNot Listed/Not Applicableâ,
âNuts/Confectionaryâ,
âOtherâ,
âPakistaniâ,
âPancakes/Wafflesâ,
âPeruvianâ,
âPizzaâ,
âPizza/Italianâ,
âPolishâ,
âPolynesianâ,
âPortugueseâ,
âRussianâ,
âSaladsâ,
âSandwichesâ,
âSandwiches/Salads/Mixed Buffetâ,
âScandinavianâ,
âSeafoodâ,
âSoul Foodâ,
âSoupsâ,
âSoups & Sandwichesâ,
âSouthwesternâ,
âSpanishâ,
âSteakâ,
âTapasâ,
âTex-Mexâ,
âThaiâ,
âTurkishâ,
âVegetarianâ,
âVietnamese/Cambodian/Malaysiaâ
]
result (JavaScript):
EJSON.parse(â[âAfghanâ,âAfricanâ,âAmericanâ,âArmenianâ,âAsianâ,âAustralianâ,âBagels/Pretzelsâ,âBakeryâ,âBangladeshiâ,âBarbecueâ,âBottled beverages, including water, sodas, juices, etc.â,âBrazilianâ,âCafĂ©/Coffee/Teaâ,âCafĂ©/Coffee/Teaâ,âCajunâ,âCalifornianâ,âCaribbeanâ,âChickenâ,âChileanâ,âChineseâ,âChinese/Cubanâ,âChinese/Japaneseâ,âContinentalâ,âCreoleâ,âCreole/Cajunâ,âCzechâ,âDelicatessenâ,âDonutsâ,âEastern Europeanâ,âEgyptianâ,âEnglishâ,âEthiopianâ,âFilipinoâ,âFrenchâ,âFruits/Vegetablesâ,âGermanâ,âGreekâ,âHamburgersâ,âHawaiianâ,âHotdogsâ,âHotdogs/Pretzelsâ,âIce Cream, Gelato, Yogurt, Icesâ,âIndianâ,âIndonesianâ,âIranianâ,âIrishâ,âItalianâ,âJapaneseâ,âJewish/Kosherâ,âJuice, Smoothies, Fruit Saladsâ,âKoreanâ,âLatin (Cuban, Dominican, Puerto Rican, South & Central American)â,âMediterraneanâ,âMexicanâ,âMiddle Easternâ,âMoroccanâ,âNot Listed/Not Applicableâ,âNuts/Confectionaryâ,âOtherâ,âPakistaniâ,âPancakes/Wafflesâ,âPeruvianâ,âPizzaâ,âPizza/Italianâ,âPolishâ,âPolynesianâ,âPortugueseâ,âRussianâ,âSaladsâ,âSandwichesâ,âSandwiches/Salads/Mixed Buffetâ,âScandinavianâ,âSeafoodâ,âSoul Foodâ,âSoupsâ,âSoups & Sandwichesâ,âSouthwesternâ,âSpanishâ,âSteakâ,âTapasâ,âTex-Mexâ,âThaiâ,âTurkishâ,âVegetarianâ,âVietnamese/Cambodian/Malaysiaâ]â)