Sunday 28 May 2017

SyntaxError: Unexpected token O in JSON at position 0

wow I'm so pissed I'm trying to figure out what the problem is for like 4 hours and still can't find any errors

so here's code

<template lang="pug">
    form(@submit.prevent='onSubmit').form
      input(type='text', placeholder='Type message here..', v-model='content')
      input(type='number', placeholder='Password', v-model='number')
      button#login-button Submit
</template>

<style scoped>
</style>

<script>
export default {
    data: () => ({
        content: '',
        number: ''
    }),

    methods: {
        onSubmit() {
            let booty = JSON.stringify({
                    content: this.content,
                    number: this.number
                })

            console.log(booty)
            fetch('http://localhost:9080/message', {
                method: 'POST',
                body: booty,
                headers: {'Content-Type': 'application/json'}})
            .then(res => res.json())
            .then(json => console.log(res))
        }
    }
  }
</script>

and I got this error from my electron app. I don't really know why it happened because literally it worked like a couple minutes ago..

Uncaught (in promise) SyntaxError: Unexpected token O in JSON at position 0



via Phillip YS

No comments:

Post a Comment