In the following code, if I remove // prettier-ignore, then prettier will transform
'Accept'
into
Accept
Which will generate a compilation error. Prettier doesn't do that on my other headers.
Is there a better solution to this than asking prettier to ignore the next line?
export default function({ $axios, redirect }, inject) {
// Create a custom axios instance
const api = $axios.create({
headers: {
common: {
// prettier-ignore
'Accept': 'application/json; charset=utf-8',
'Content-Type': 'application/json; charset=utf-8'
}
}
})
api.setBaseURL('http://10.10.10.5:8088')
// Inject to context as $api
inject('api', api)
}
The Vue2 error if I do not enclose the headers names with single quotes:
Syntax Error: Unexpected token, expected "," (9:11)
common: {
Accept: 'application/json; charset=utf-8',
Content-Type: 'application/json; charset=utf-8'
^
}
.prettierrc.json:
{
"tabWidth": 4,
"useTabs": true,
"semi": false,
"singleQuote": true
}