Skip to content

Conversation

mangobiche
Copy link

@mangobiche mangobiche commented Apr 16, 2025

Description

This PR adds support for array responses from the message.url endpoint in the Message.vue component. It ensures that if the response is an array (as is the case with some public APIs like zenquotes.io), the component will correctly use the first item in the array as the message.

Changes

  • Updated mapRemoteMessage() to check if the response is an array and use the first item.

Fixes # (issue)
Optional message #750

How to test

  1. Use a message config that fetches from an endpoint returning an array.
  2. Confirm that the message is now correctly displayed using the first object in the array.
message:
  #url: ./assets/quote.json
  #url: https://zenquotes.io/api/random CORS error
  url: https://corsproxy.io/?url=https://zenquotes.io/api/random
  mapping:
    title: 'a'
    content: 'h'
  refreshInterval: 600000
  style: "is-primary"
  title: "Quote every 10m"
  icon: "fa fa-quote-left"
  content: "Loading quote..."

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I've read & comply with the contributing guidelines
  • I have tested my code for new features & regressions on both mobile & desktop devices, using the latest version of major browsers.
  • I have made corresponding changes to the documentation (README.md).
  • I've checked my modifications for any breaking changes, especially in the config.yml file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant