@LichtZinnig wrote:
Hi, I’m new to Ember (and fairly new to JS and programming altogether).
I’m trying to create a Helper called random.js that will fetch a JSON object from an external API, and return one string from that object to the Template that calls the Helper. I’ve created this (and dozens of variants of it):
import { helper } from '@ember/component/helper'; import fetch from 'fetch'; export function random() { return fetch('https://www.randomtext.me/api/gibberish/p-1/20-40') .then(res => { return res.json(); }) .then(body => { return body.text_out; }) } export default helper(random);
The Helper keeps returning an object, even though body.text_out is exactly what I need (and it is of type ‘string’). Any advice on how I can make this Helper return the string body.text_out to the Template?
Posts: 1
Participants: 1