Ejemplo n.º 1
0
 ({ok, status, body: {error}}) => {
   env.swap(pipe(
     alter(putIn, xhrPath, null),
     alter(putIn, xhrMessagePath, ok ? okMessage : null),
     alter(putIn, xhrErrorPath, ok ? null : error || `Unexpected error (status ${status})`),
   ))
 }).start())
Ejemplo n.º 2
0
function request (read, env) {
  const okMessage = 'Thank you! We will contact you as soon as possible.'

  env.swap(pipe(
    alter(putIn, xhrMessagePath, null),
    alter(putIn, xhrErrorPath, null),
    alter(putIn, xhrPath, Xhr({
      url: 'https://formspree.io/info@purelab.io',
      method: 'post',
      headers: {
        accept: 'application/json',
        'content-type': 'application/json;charset=UTF-8',
      },
      body: {
        email: read(...emailPath),
        name: read(...namePath),
        message: read(...messagePath)
      }
    },
    ({ok, status, body: {error}}) => {
      env.swap(pipe(
        alter(putIn, xhrPath, null),
        alter(putIn, xhrMessagePath, ok ? okMessage : null),
        alter(putIn, xhrErrorPath, ok ? null : error || `Unexpected error (status ${status})`),
      ))
    }).start())
  ))
}