0

First of all, when I input "Tomorrow noon", the system output "2019-09-21T12:00:00+08:00"(parameter: whattime). When I inputted the word – "Tomorrow noon", the system would convert it into whatime: {"date_time": ""2019-09-21T12:00:00+08:00"}.

Second, there's only time to show it up after inputting a period of data. (you can check this picture I posted). How do I fix my codes?

function saveDataHandler(agent){
    const{
      namelist, howmanypeople, whattime, forhere
    } = agent.parameters;
    const data = [{
      Name:namelist,
      Number:howmanypeople,
      Time:whattime[1],
      Forhere:forhere
    }];
    axios.post('.....it's about API', data);
  }

enter image description here

TheMaster
  • 45,448
  • 6
  • 62
  • 85
李宇澄
  • 53
  • 1
  • 2
  • 7
  • [Edit] to 1.Show apps script code 2.Apps script stackdriver logs 3. Why `[1]` in `Time:whattime[1]`? Why not just `Time:whattime`? – TheMaster Sep 21 '19 at 07:54
  • When I inputted the word – "Tomorrow noon", the system would convert it into whatime: {"date_time": ""2019-09-21T12:00:00+08:00"}. So, it's only this data which couldn't be able to store in the Sheet. That's why it's not suitable for your answer and also I'd tried it before. However, it didn't work. – 李宇澄 Sep 22 '19 at 09:27

1 Answers1

0

If whattime value is whatime: {"date_time": "2019-09-21T12:00:00+08:00"}, you should access date_time in whatime before sending it.

const{
      namelist, howmanypeople, whattime:{"date_time":dt}, forhere
    } = agent.parameters;//modified 
const data = [{
      Name:namelist,
      Number:howmanypeople,
      Time:dt.toString(),//modified
      Forhere:forhere
    }];

OR

const{
      namelist, howmanypeople, whattime, forhere
    } = agent.parameters;
const data = [{
      Name:namelist,
      Number:howmanypeople,
      Time:whattime["date_time"].toString(),//modified
      Forhere:forhere
    }];

To read:

Community
  • 1
  • 1
TheMaster
  • 45,448
  • 6
  • 62
  • 85